Your choice of what you should be doing after 40+ should be based on not only what interests you but also what your environment may expect when you reach 40+. Looking at what 40+ people doing at your company gives you a clue of what is expected of you when you turn 40.
Hedge fund might be an exception like academics and research. In most non-research oriented companies you will see more 40+ in management than in programming. Like you mentioned FoxPro people having bad time, even if you are skilled in latest 'programming' trend, a company might prefer (IME, most of the time it is true) someone younger than a 40+ in that role. For most companies, the marginal utility of a person plateaus or declines after about 5-7 years of progressive experience.