If the string is too close to the pickup, the magnet prevents the string from vibrating freely.
That's the received wisdom, however it's going to depend on the "tug" of the pickup and the gauge of the string.
Think of it this way: imagine a 50ft rope, as thick as your wrist, stretched tight between two points. "Pluck" that rope and now try and make it stop vibrating using only pressure applied with your index finger at one point. Chances are pretty darn good that the rope will keep vibrating for a while, despite the applied pressure. Okay, now pluck a .009 gauge high E and put your index finger on it. Chances are pretty darn good it will come to a dead halt, milliseconds after you touch it.
Most polepieces are not going to be so strong that they exert significant tug on anything but the very thinnest-gauge strings, unless the string-to-polepiece distance is so slender as to practically prevent picking. Besides, once you plug in and the amplifier volume exerts a little vibrational stimulation of its own on the guitar body, the influence of that physical vibration of the body will be stronger than the polepieces. The amp will tell the string "Keep moving!" much louder than the pickup will say "Sit still!".
As well, consider the case of "horseshoe" pickups, that place magnets below
and above the strings, with a narrow space between. If pickups' magnetic tug on strings killed sustain, those pickups ought to result in strings that decay mere moments after you pick the strings. Instead, horseshoes seem to have much
more sustain than regular pickups, which is why slide players love 'em.
Bottom line: Adjust height for tone, but don't think you're adjusting for sustain. (I might make an exception for the low-impedance pickups on the Les Paul Recording and similar. My recollection is those suckers have some
serious magnets.)