There's a fallacy that we all fall into: We think that our job is about turning the crank, and that the best crank turners will stay around the longest.
It's not: I've been involved in quite a few projects that get abandoned, (or otherwise miss their target) for one reason or another. There's a few things that you (or your partner) can do to protect yourself.
Most important: Make sure that your role (as an engineer) in your company is in the most critical part of the company as you can handle. When budgets get cut, it's not the best "crank turner" who keeps their job; its the people in the most critical roles for products (and projects and processes) that the company no longer can fund. (Note that this isn't foolproof, because foolish management can still goof and let you go.) (Note that in large companies, this is much harder because you can become critical in a niche that the company decides to divest from. To handle this, move into a subsidiary that would be sold as a unit.)
Secondly: Understand the business cycle. All products (and projects and processes) have a lifetime, and at a certain point they are "done." (As in, not worth investing in paying the best crank turner or the most critical person to keep working on it.) When you smell this happening, let it be known that you're open to severance when the budget gets cut. It's always easiest to let go of the person who's willing to take severance because they're ready for a change in scenery.
Next: Make sure you can get a feel for how the product (project, process, ect,) is actually used. You might have turned the crank really well, but if no one is using the result, it's time to be proactive and move on.
Finally: Learn to judge your management, and build relationships with your boss's boss. This will give you a lot more insight into the company so you can learn when to move on or how to position yourself in the most critical part of the company.
All good advice, I do disagree with one statement, however, mainly because I've seen this getting violated many times now:
> "Make sure that your role (as an engineer) in your company is in the most critical part of the company as you can handle."
The main problem here is how much the organization wants to think it can continue without those crucial parts, I've seen wild things go down in this regard, and I think we'll see a lot more in the near future with people hoping that AI will take care of it. And, on the flipside, and much to my surprise, how often the org can actually survive through such disaster cuts regardless, even though they'll end up at a worse place than they were at before, but the simple act of surviving it -- at that point -- is enough of a success to continue onwards.