On-sky closed loop correction of atmospheric dispersion for high-contrast coronagraphy and astrometry