This question has a specific and a general sense.
Eventually, if your game runs long enough, a party will be pretty much maxed out - reaching level caps, wielding top-level powers and abilities, dispatching the most fearsome enemies. There are monsters and encounters that can challenge even the toughest parties, mechanically speaking, but in terms of narrative, there's only so far you can go. Speaking D&D-specific for a moment, I've seen monster specs for some of the 4e gods. Once your party has killed a god (or several), there's not much to go "up" to from there.
Also, even if you can think up a tale that justifies a string of high-level encounters of that sort, with no more skills or abilities to gain the players will no longer be able to develop their characters beyond free-form RP, so gameplay might get a bit repetitive (my players love gaining and trying out new skills... with nothing new to gain, I fear they'll get bored).
So, the general question is: how do DMs deal with this?
In a more specific sense, I had an idea a little while ago for an encounter (D&D 4e) that basically ends with the party being "retired". The basic gist is that the campaign ends with a choice: leave yourselves an exit, and know that this also leaves the chance for your foe to return someday, or make the ultimate sacrifice to defeat them permanently. It wouldn't be a death as such; the characters would still exist but would be trapped beyond the mortal realms. (If anyone's familiar with the Thomas Covenant books, think of the bit where he gets trapped inside the Arch of Time). As a DM, I'd love to have the characters show up as NPC demigod/guardian angel/Ghost Of Encounters Past thing, and I think my party know that I'm the sort to do something like that. Do you think a party is likely to take the latter option and end their characters' stories?