I'm in my forties and I have found over the years there is no technical career path at most companies for a programmer/software engineer/developer as a perm employee past the senior or lead software engineer/developer position, except for a few architect positions that seem to be difficult to get.
Everything else above the senior developer level seems to be project manager, director, or CIO positions where there is a lot more management/meetings and it is much less technical.
So, I would say consider setting up your own company and doing independent consulting. That way you can just help companies out when they need it and continue to stay on the technical side of things. Depending on what your skills are, your rate as an independent consultant will probably exceed what you would make going into management anyway.
I've been doing nothing but contracts for almost 4 years now and almost every week a recruiter or someone is asking me if I'm available for a contract. I haven't noticed any age discrimination yet. I've seen guys in their 70's still working contracts along with me and doing fine. I think the key to keep going is "attitude" and the willingness to learn new things. As long as you keep that, I wouldn't worry. It might also help that as a contractor, I carry my own insurance for health and disability, so whatever company hires me for gig doesn't have to worry about the higher health/disability premiums I might have if they hired me as an employee.