A significant fraction of massive main-sequence stars show strong, large-scale magnetic fields. The origin of these fields, their lifetimes, and their role in shaping the characteristics and evolution of massive stars are currently not well understood. We compile a catalogue of 389 massive main-sequence stars, 61 of which are magnetic, and derive their fundamental parameters and ages. The two samples contain stars brighter than magnitude 9 in the V band and range in mass between 5 and 100 Msun. We find that the fractional main-sequence age distribution of all considered stars follows what is expected for a magnitude limited sample, while that of magnetic stars shows a clear decrease towards the end of the main sequence. This dearth of old magnetic stars is independent of the choice of adopted stellar evolution tracks, and appears to become more prominent when considering only the most massive stars. We show that the decreasing trend in the distribution is significantly stronger than expected from magnetic flux conservation. We also find that binary rejuvenation and magnetic suppression of core convection are unlikely to be responsible for the observed lack of older magnetic massive stars, and conclude that its most probable cause is the decay of the magnetic field, over a time span longer than the stellar lifetime for the lowest considered masses, and shorter for the highest masses. We then investigate the spin-down ages of the slowly rotating magnetic massive stars and find them to exceed the stellar ages by far in many cases. The high fraction of very slowly rotating magnetic stars thus provides an independent argument for a decay of the magnetic fields.