I'm 46 and still employed as an SWE - got my current position 3 years ago. The key is to not let your skills stagnate, and to always be playing with something new - even stuff that you may not think you'll use in your career. For instance, for the past several years I've been playing with machine learning with a focus on self-driving vehicles. Do I think I'll ever get a job working in that field? Not likely, but the skills I have learned may be useful down the line (and personally, I've been pursuing such an education for my hobbyist aspirations).