Perhaps also luck, but I’ve managed to have a spidy sense for when things are going the wrong way, and got out / moved on before it got that bad.
It’s really a bunch of little things that, when seen as off all at once, will trip your spidey sense to jump ship.
If you don't have visibility into that, there are other warnings signs, like various spending cuts. No straight answers to questions about that stuff.
Not providing visibility into the business is also a warning sign, in my opinion.
I've also left companies when they started making pretty weird business bets that I dind't think would pan out.