Might I suggest that you might not know enough 40- to 50-somethings to sling around that word "most"?
Sure, as an old fart, I don't like the new culture of the young snots that change jobs every 18 months before they've started to add value, or even really learned anything, but that's about as much time as you'd get from an overqualified person looking to bide his time before he moved on anyway.
It also doesn't fit other software devs I know who are similarly old.
In Toronto, I've worked with 60+ years olds getting paid six figures as 'c++ developer'.
I've also worked with 40 year olds hired as 'frontend engineers' unable to get more than $35k.
So yea, maybe your statement is true if you are only after job, but if you treat this as a career, there are no limit to opportunities.
Most 40- or 50-somethings in tech would be happy just having medical and getting to retirement w/o having to sell their house or raid their 401K.