A GM would probably think of allowing a Mulligan at this point, or ignore the results of the characters' actions and the players' dice rolls, perhaps pull a deus ex machina out of his ass. I've probably done it myself. But letting the TPK happen could conceivably provide fertile ground for gaming. Here are some options for enterprising gamers...
Total Party Knockout
You'll need sentient enemies for this most simple of solutions (if the party fell into molten lava, you're out of luck). Essentially, the characters weren't dead, just rendered unconscious. They wake up with a fraction of their hit points, captives, hostages, test subjects, or slaves. It's not a cheat, merely a PERCEPTION of danger. They'll be glad to be alive, and have new challenges to face.
It Was All a Dream
Now THIS is a cheat, and I've had a GameMaster do this to me after total party killing his long-standing group (along with try-outs like me; we never returned). Awkwardly hesitating while his friends screamed at him because their high-level characters were dead, then deciding to say it "all an illusion" DID seem like a cheat. So whatever you choose to do, keep your cool, that's a lesson I learned that day. How DO you make the dream work? Have one character wake up in cold sweat; it was the anxiety talking. So the other characters were just figments of the imagination in those scenes; that was surely done for effect, to make it feel real. The best version of this idea makes the dream premonitory. The action repeats and they realize it was prophecy - can they change their fate? Another version takes a page from heist movies and ends not with a character waking up, but with his or her plan shouted down by the others. If your group has just rested up, or if they're big planners, either of these options might work.
They died for realz, but are resurrected some time later. Undead? Clones? Divine intervention? Faked their own deaths the way superheroes and superspies tend to? That really depends on the campaign world. It might also come with new problems, that way, they really do pay for their blunder. A clone might need to build all that muscle again. Someone raised by a necromancer would have all the classic weaknesses of the undead. Don't be afraid of taking your story into bizarre territory.
The Next Generation
They died for realz. Again. And no raising the dead, this time. Instead, the villains have won, and some time later, a new generation of heroes rises up to take the place of their parents (grandparents? granduncles?). This formula allows the GM to change the campaign world for the worst and create loads of new opportunities for gaming. Not only that, but the one-scenario villain takes on an epic quality - he killed the realm's great heroes and changed the world in his image.
A variation on the deus ex machina that might work in campaigns where super technology or high magic are possible is to have future versions of the characters be the instruments of their own salvation. You've just branded the time line one that's been tampered with and probably outed the villain as a time traveler, and that's bound the send the campaign spinning into epic territory. Wouldn't it be fun to replay the rescue from the other perspective when the time comes?
Oh You Thought THEY Were the Protagonists?
When characters are new and inexperienced, they may be more vulnerable to Total Party Kills. What do you do when the dead party was made up of neophytes the players hadn't fully invested in? Is it worth salvaging the campaign? If the players are open to it, how about using the event as the kind of twist we sometimes see in movies? We're following characters and assume they're the heroes. BAM! They're wiped out. And we realize the story is really about the group that killed them, or the people who investigate their murders, etc. And these new characters, I bet the players won't be making the same chargen mistakes they made when the system was too new to them, right?
Death Is the Beginning, Not the End
You liked the characters and their dynamic, but aren't married to the setting? How about this: The characters die and all wake up on another world. They are themselves as far as personality and general ability go, but the previous campaign was either an elaborate simulation, or they've been "reincarnated" (as adults) in this parallel universe. And maybe it's a jump they make every so often, cursed to sacrifice themselves again and again, going through the GM's large RPG collection...
Man, that almost makes me WANT to cause a Total Party Kill. What have I just unleashed?