In the long run you'll want to make sure your job remains enjoyable. One problem with getting older is that you tend to have less time/endurance to pursue spare time programming.
I found that I had to plan very well, about 3 years, to get where I wanted to be. After being stuck in a small business for about 6 years, I found, not surprisingly, no place would hire me for technical, non-business programming anymore. I went back to school for an MSCS, learning newer concepts (e.g. threads, concurrent programming, etc). I now work at a large science lab (1000s of people), so there is plenty of room to move around. I have had to avoid business programming, management positions, and dead-end technologies, but that's not unexpected. It has worked pretty well for the last 10 years.
bluto