In my experience, the method described here works very well in practice:
http://wwwf.imperial.ac.uk/~rn/distance2ellipse.pdf
(this is linked to from the stackoverflow post)
Finding the closest point for an ellipsoid is more challenging in practice, because one needs to take a different parametrization near a pole, and sometimes conjugate gradient is necessary to get convergence.