It's something that comes with experience.
If you've had projects like this in the past you'll recognise the early warning signs (eg. hard deadline before (even rough draft) requirements are available).
You'll know it's time to start the job hunt early because there's no way it can work unless you work yourself 24/7 into the ground.
It's not about accepting defeat, it's about accepting you are worthy of something better.