A first class medical does not expire and leave you grounded. It steps down. Under 14 CFR 61.23(d) the privilege periods all start on the day of the examination and run concurrently, so when the twelve-month ATP window closes, the same certificate carries on serving commercial privileges, and then private privileges, for the remainder of their own longer periods.
Worked example. You take a first class exam in March at age 36. ATP privileges run to 31 March the following year. Commercial privileges also run to 31 March the following year. Private privileges run to 31 March five years out. One exam, three different dates, and the certificate in your pocket is still perfectly valid for private flying four years after it stopped being valid for the airlines.
The other thing people get wrong is the age test. The FAA uses your age on the date of the examination, not your age now. Turning 40 the week after your exam does not shorten the certificate you already hold.
And every period runs to the last day of the month, not the anniversary of the day you were examined. An exam on 3 March expires at the end of March, not on 3 March.