Everyone's circumstances differ but I'd say get out if you can.
I spent the first half of my working life in science, mostly trapped at the top of my pay scale in a place that simply didn't offer promotions and in a job that I'd only taken on as a temporary measure until there was an opening in my preferred field. Eventually I found myself heading into the situation in the article with too many people wanting a piece of me. Things worked out doubly lucky. Firstly I had had some programming training and experience previously; we were early adopters of a RDBMS & Unix in lab management & it was largely my baby so I had a jumping-off point to get into IT. Secondly we'd worked out previously that we were coming up to one of the dates were we could move without too much disruption to schooling. I managed to get a techy IT job and handed in my notice - at which point I was offered a promotion to stay, no board, no formalities at all. Bloody cynics. Or maybe they thought that was what I was really aiming for. Anyway I took up my new job, a complete career switch a few days short of my 42nd birthday. If you've got the right skills to offer age might not be a barrier but more of that below. Actually the schooling bit didn't work out as well as we'd hoped. It took months to sell the house and I spent months in B&B with very little chance to visit back home - somewhat traumatic all round. However, the release from stress was so great that workwise it felt like an extended holiday.
Roll forward another decade and a few job changes in IT (yes job changes in my 40s and also a relocation, spot on the other date we'd identified) and I was fed up with being managed by idiots. By this time I was just short of my 52nd birthday. After failing to suppress disbelief or conceal disgust at a particularly bad [de]motivational event I was made an excellent early retirement offer as from the end of the year. Maybe another permie job would have been too much to expect at that point but freelance was the solution there - age doesn't matter as far as I can see, in fact it's advantage if you have the kids off your hands. Actually, as it happened I had to turn down a permie job offer from a client - it was management and one reason I was freelance was to avoid that sort of crap.
After a further 10 years freelance I was eventually pushed into retirement by sheer annoyance at vacillating micromanagement by a client's development manager. Between his assigning jobs at the end of the day he was leaving on holiday and my getting home he'd reassigned them again at which point I decided I just didn't need to put up with any of this any more.
So, to reiterate, getting out might be feasible and, if you can manage it, could be the best solution as it draws a line under everything that's gone before. And freelance is an age-independent means of doing that.