> In hindsight, I should have quit long before the company got into such dire straits, but it was an easy commute, and the co-workers were great people to work with
Not as experienced as you but as a younger guy I would like to share my experience - I lasted 4 years and few months before I was asked to go. Even though I never considered myself irreplaceable in a firm of 6K+ coders, it was a revelation how "business strategies" may "require you to be let go" which would be of course "better for your career". Finding another job was super easy for me (I believe that was because of my young developer age). But I was really bitter about the "let go" process and the way things were handled. It was only after few months that I realised that it was actually very good for my career and yes when I look back I see I should have left the place at least 3 years ago when things had started to change and I still didn't act. It was just a good salary, a very tightly knit team, and a relaxed work environment. I had gotten into the comfort zone. When I was out I took that long cherished 3 months cross country solo backpacking trip.
As for the emergency fund - yes, even for a younger person like me with no responsibilities or liabilities a medical insurance (I had been paying for one since I had joined - here in my country medical insurance in general means whatever your firm offers me and usually no one buys any medical insurance on their own) was something I had along with regular transfers from salary account to few deposit accounts and into some equity funds.
> Once you are over 50 like me, you need to be in a position financially to live several years without a paycheck
This! I have been planning for this as a retirement strategy now. Actually as an "involuntary retirement" strategy. It might sound naive and may actually be naive but when I am planning for my MS now, this is one of the use-cases I have in mind. With an MS I will have another career option (or rather call it freelancing) - teaching in colleges and universities as adjunct/visiting faculty. One of my lecturers (actually one of the better ones) did not have a PhD. He told us he was laid off from his job and he didn't want to find another job in the industry and he was considering a PhD (he was 53 at the time). He taught in some other colleges too.
And yes, a company may ask you to go at the first sign of trouble and hence I find it incredibly surprising when employees leaving a company at the first sign of trouble are frowned upon and are often called "disloyal" by some people.