We present a study of the dynamics and magnetic activity of M dwarfs using the largest spectroscopic sample of low-mass stars ever assembled. The age at which strong surface magnetic activity (as traced by Hα) ceases in M dwarfs has been inferred to have a strong dependence on mass (spectral type, surface temperature) and explains previous results showing a large increase in the fraction of active stars at later spectral types. Using spectral observations of more than 40000 M dwarfs from the Sloan Digital Sky Survey, we show that the fraction of active stars decreases as a function of vertical distance from the Galactic plane (a statistical proxy for age), and that the magnitude of this decrease changes significantly for different M spectral types. Adopting a simple dynamical model for thin disk vertical heating, we assign an age for the activity decline at each spectral type, and thus determine the activity lifetimes for M dwarfs. In addition, we derive a statistical age-activity relation for each spectral type using the dynamical model, the vertical distance from the Plane and the Hα emission line luminosity of each star (the latter of which also decreases with vertical height above the Galactic plane).