I'm 47 and generally code six days a week. I've done' the management ascendancy a couple times and have worked for (or co-founded) four start-ups and I worked for one large company. I've kept my skills up-to-date and now command a very high salary.
So with my mini-bio out of the way, I'll caveat my answer a bit ... I think a true programmer loves what they do and wouldn't be satisfied with any other role. So I've pushed my way back into development and I'll stay here until I die (I can't imagine retiring). I think the other class of programmers are people that got into the craft because they heard it was a well-paid gig, and thought that their college provided all the education they'll ever need ... they're generally gone in under ten years. Either into management or other careers altogether.
We look at the young kids and think "What chance have they got".
We've had decades to assimilate Basic (C64), Assembly (6502, 68000 and Z80), C, Pascal, Serial Comms, Linux, Windows, X, ASN.1, C++, STL, OO, Patterns, UTF-8, Java, Lisp, Ruby, CSS, SQL, HTML, XML , XSL, XPATH, JSON, Node.js, Punch Cards, Boost and all the other stuff I've forgotten.
And guess what, once you've been to about 20 interviews all the questions are the same. So you better hope you don't come up against us.
1) Learn a domain, one with staying power.
2) Stay in shape. For me, this means limiting how much I eat. I find that consuming a minimal amount of carbs/sugars totally eliminates the ups and downs in energy levels throughout the day, and makes me feel as ready to go at 4PM as I do at 9AM.
3) Enjoy yourself. There are thousands of domains for programmers. Find one where you like the culture and work.
4) Consider moving away from the coasts. The concentration of competent developers is much lower in the interior of the country. (Just 100 miles can make a big difference).
5) Don't go into management, unless you really enjoy it. And if you do become a manager, hack management.