older developers are one of two things: a wizard or burnt out. I have worked with many older burnt out and useless guys my age. They still have all the knowledge within them, the only thing is they have no spark, no desire to continue to learn or continue to innovate or, sadly, to continue to contribute. I call them the working welfare.
All my interview questions start with:
What's your passion?
The candidate's truthful answer will tell you all you need to know.
I'm also 40, still love to code, but have a family and other passions now (mostly bike riding and trail building) which mean I'm no longer as dedicated and driven as I once was (to code).
10 years ago I would work on my own projects until 2 or 3 in the morning and then head to work to code some more, as well as on weekends. Not any more though, unless it's really needed, and as a result I think I'm healthier and have a far better work-life balance, and I hope in 10 years from now I'm still doing the same thing.
I'm still productive and wouldn't consider myself useless or working welfare. As well as coding, I admin our build server and version control for a team of ~50 with many products. I just built my first domain specific language, and am eager to see if I can add auto-completion to it. Neither do I consider myself a wizard, I just have experience and that helps, if nothing else, to avoid the traps that are easy to fall into when building software.
Hopefully that's a reasonable example of how we don't all fit into the "wizard" or "working welfare" classes.