Your adventurers are fighting your giant Leukodaemon. Things are going well and then it pulls out its giant +# "angry adjective"greatbow and stuff turns deathly unhallows.
In this brief moment the DM must now consider Play Death. As opposed to a societal contract formed between the DM and the dead meat as suggested by previous bloggers I support the Choke Em Out method.
First off, PC death must be done slowly. In order to keep the proletariat happy you must lull them into their own slow death in such a way that makes the PC's think that it is nobody's, or perhaps even their own faults (the latter is preferred). Diseases can be useful in this regard but even the most penny pinching of Pc's will figure out a way to get their hands on remove disease. Negative levels are nice because the PC is still very much alive but suddenly that lvl 1 goblin could sound their demise quite easily.
The most surefire way is to bet on their own lack of foresight. Wear down their spells and hit points with low level encounters. Having a lot of monsters on the board can easily shock a group into thinking the ECL of an encounter is a lot higher than they think. They'll use up a bunch of spells, the low lvl priests will consistently do six points of damage per priest per round, and if they can the PC's will use up healing fixing up this minor damage. Even better is the false boss battle. They'll use up almost all of their reserves, they'll take some damage, and even better they won't both sleeping/ healing because they'll assume that all of the following rooms are just piles o' treasure as apposed to the even bigger giant robot crab. Even better still, you can do this as many times as you want. You can have four or five of these in a row and so long as the PC's think that the last one was hard enough they'll keep going.
Finally make sure that all bridges are burnt. Once you've killed one PC you have to kill all the rest quickly or they'll return with reinforcements and resurrections for the rest. Once you've taken them all out make sure that they won't be able to conveniently be saved. Acid works good as it will destroy any body parts that could be used for clerical work and also be sure to burn their house/base of operations down for they may have been smart and hidden some DNA there. Now once they are all dead PC's have this odd notion that they then need to build new characters in order to continue the quest onward. In order to make sure this doesn't have you must be sure to salt the Earth. Have that demon the PC's failed in killing eat the world or proclaim one of the dead PC's as the Chosen One so that in their death all hope is lost.
Now that all continuation seems pointless as the Dungeon Master you will suddenly find yourself with such a large amount of spare time you won't know what to do with it all.
You're welcome.