In the past, I've mostly dealt with that by simply ending campaigns before they got too high into levels that I didn't want to play. This has mostly worked out very well, but occasionally, I end campaigns that I still think have some good life left in them, or that I'd want to revisit later.
Luckily, some of the fine folks who post at ENWorld came to the rescue and started talking about a top hat houserule system called E6 that governed character advancement, and is designed to keep D&D in a perpetual "sweet spot" loop, no matter how long you play.
I won't link to the actual discussion and document; I'll just summarize the gist of it, how it works and all that, but without all the theory.
Characters advance as normal up to 6th level. Once they hit 6th level, they can no longer advance in levels. For every 5,000 experience points they receive above 6th level, a character may take a feat. Every ten feats amounts to an effective level increase in terms of challenges that the PC's should be able to face, up to about 10th level, at which point the difficulties of bringing all the feats a character has to bear in any given encounter reduce their efficacy in terms of advancement.
That's it in a nutshell. But I've added a few other things to the pot as well.
Class abilities for levels above 6th level can be converted into feat chains. In every case, this requires working with the GM to make sure that it is OK, but as a general rule, each level's worth of abilities must be taken in order; i.e., before you can take a class ability that you would have received at 10th level as a feat, you must first take all the class abilities for 7th, 8th and 9th levels as feats as well. This does not apply to class abilities that are improvements on existing class abilities, i.e. you cannot convert new spell levels into feats, or increased sneak attack damage, or other such abilities.
This means, among other things, that no spells higher than 3rd level are generally available. However, the rules for Incantations (found in Unearthed Arcana or Urban Arcana) can bring higher level spells into the game as needed.
Prestige classes do not exist under this top hat houserule, but prestige classes can also be converted into class ability feat chains by working with your GM to smooth over any inconsistencies and ensure that reasonable requirements are met.