Another example is that really through no fault of my own I had to swap employers several times in a relatively short amount of time, I know I could explain it well in an interview but it raises flags if you're just glancing through my CV. So now I'm planning to stay with my current employer to build credibility that I can commit and won't just head for greener pastures in less than a year.
Same situation here. Where I am now, I'm one of the youngest devs at 47, and the majority of the rest of the dev team have been there in excess of 20 years. The environment is a little stagnant technically (although they're making a good-faith effort to bring things into a more modern setting) and the job is kind of a "it's time to make the donuts" kind of gig for me, but my boss and all of my co-workers are really easy to get along with and geeky enough to want to learn new things. They're also very forthcoming about the vast amount of institutional knowledge they all have, and everyone is happy to answer questions about anything at all. I have a much better degree of job security now, and I continue to keep abreast of new developments in the industry and do plenty of work with more timely and relevant tech on my own time so as not to get stale myself.
The key thing is just to never stop learning, even if it's outside the scope of your current employment. There are far too many people in the development field that don't take an active interest in what they do for a living. For me, learning new things is mostly its own reward, but having competency with a wide breadth of relevant skills sure helps a lot when you're looking for a new job.