There must be 50 ways to save that party!
Let them slip out the back, Jack,
Make a new plan, Stan,
no need to destroy, Roy,
just listen to me…
In event of an immanent unacceptable TPK roll 1d8 on each table.
1. capture them
4. turn on each other
5. become distracted
6. change sides
8. are defeated by a miracle. (Stop. Do not roll on because.)
1. somebody the party once helped arrives*
2. an old enemy of the party arrives*
3. an enemy of the foes arrives
4. a powerful supernatural entity intervenes
5. an unforeseen disaster occurs
6. they mistake one of the party for somebody else
7. they have a change of plans
* substitute a mysterious stranger if the party has no plausible old enemies or allies.
Note that in many games TPKs are entirely acceptable, or acceptable under certain circumstances. This is just for the times when a GM wants to stop a TPK in progress without fudging the dice.