One thing that stood out to me though is that a lot of the older candidates I interviewed that had been struggling had deep knowledge of a technology that's no longer used and had had very little interest during their career in learning new things outside their job. So once the thing they were expert in was no longer fashionable, they had a hard time catching back up.
I know it's unfashionable to say this and I know that a lot of people have full time jobs and don't want to have side project additionally to their full time job but if you want to keep a career as a software developer past 40 without going into management then you need to do side projects,you need to keep up to date with some of the latest fad (even if some of those fads are cyclical and recycle concepts from 20 years ago). Doing a job well and becoming an expert in an obsolete technology is no path to career growth.