You have to make sure that 2 or 4 young/cheap programmers can not replace you. It's not like programming is the only skill for programmers. You have to understand the product you're making, how the team works together, how the different parts work together, etc. Become indispensable. Work for a company that doesn't do the latest and greatest fad (getting involved with fads is a short road to a short career). If all you do is know how to tie together different libraries and understand the syntax, then yes, you'll lose your job to the cheapest one out there.
There are more types of things to be in the career other than just junior grunt and elite manager.
The good jobs are the ones with actual job requirements listed, things other than "$x years with $new language". Experience is highly valuable. You can't take a recent grad willing to work for beer and hot dogs and have them design the next system. Chances are they're going to be hunting down your experienced staff for help on how to debug something simple.
Because if they're going to toss away a good programmer in order to replace with cheaper workers, then believe me they will also toss away the good managers too and replace them with cheaper ones. If you can't find a job as a 50 year old programmer then chances are you're going to have much difficulty finding that 50 year old management position (especially when all the CEOs are 20 something Harvard dropouts who don't think old people are relevant anymore).