It's hard to tie things up in a campaign, to leave characters and stories behind.
Most gamers I know don't ever get to end their campaigns. One day, a schedule conflict intervenes, or someone moves, and the game coasts off into nowhere land, a place the group always wants to return to, but can't ever seem to find the time, the same players, or the interest. Too often we build epic campaigns that we don't have the time to play out to the end. This is why (in my opinion) we should figure out a likely end point to the campaign as soon as it hits its stride, you've figured out what it's basically about, and some interesting things you'd like to do with it. I'm beginning to realize that you should start heading in that direction as soon as the campaign starts to feel awesome. You can often bring back a campaign you've concluded--but it's a rare thing to finish a campaign that's lingered for years unresolved. New things come up. You move on.
So, how exactly does one end a campaign?
I believe a story is a promise that the storyteller(s) make, and the campaign is the exploration and fulfillment of that promise, that story. The ending needs to tie up most of the major themes explored in the campaign as well as the personal goals and conflicts of the characters. It's usually best not to try accomplishing all of this at once. Some characters may find their endings before others. The minor conflicts resolve first, leading up to the resolution of that big conflict.
What's a conflict? In D&D we usually think of a fight with a villain, and that's certainly the straightforward way to go about it. But I think there ought to be more to it than that. If you pay close attention to the campaign you're running, you'll notice some recurring patterns--themes--within the story as a whole. They can be abstract concepts (sacrifice, honor, justice ) or they can be more tangible goals (home, vengeance, redemption). In our current mini-campaign based around old AD&D modules the themes are all very concrete: slavers/slavery, devil worship/corruption, barbarism/ruin. I didn't plan this, I noticed it as we played the modules and the characters came out.
Nevertheless, you have to be careful with an ending. You may be the DM, but your players have been interacting with your story, playing your story, investing in your story. I would caution DMs and designers from trying to be too clever as much as I would warn you against being too blunt. The perfect ending satisfies the major questions and themes of the story but it leaves something to speculate upon.
Where endings go wrong is when they try to wrap up every last detail, bogging down and obscuring the important points of the conclusion, and vague avant-garde endings too clever for their audience. That said, people have different ideas about what makes a good ending. Some will not be satisfied until every last detail has been revealed. I would argue that that's their problem and not yours. On the other hand, if the story promises to reveal the answers to their questions--and that's what brings people back time and again--the storyteller has an unspoken contract, an obligation, to that audience, to deliver on the story promise, the precedent he/she establishes.
Here are some series that essentially deliver on the promise that the story established:
Lord of the Rings
Star Wars (original trilogy)
Avatar the Last Airbender (the tv series)
Slings & Arrows
Here are some series in which the end (in my opinion of course) didn't deliver on the story promises:
Star Wars (prequels)
The Dark Tower
There are a whole list of other shows and movies that were rushed or canceled prematurely, but those are harder to address since they simply don't have endings, or they had endings tacked on once it turned out the series was no more. For example:
It's worth noting that some endings have been redacted after audience response. Arthur Conan Doyle's attempt to kill of Sherlock Holmes, for example, went over like a lead balloon. And honestly, inventing Moriarty all of the sudden to be Sherlock Holmes's arch nemesis, and then using him to kill off Sherlock Holmes in the span of a single story... that was pretty lame. We look on the work as a classic, but we have over a century of perspective. If it happened today, we wouldn't be so keen on it. So, following public outcry and much gnashing of teeth, Doyle brought Holmes back from the dead and continued to write about him. Consequently, after similar ending outrage, Bioware has agreed to redo the end of the Mass Effect series after going for a conclusion that largely confused its audience.
Thing is, when you conclude a campaign or a story, you have to take your audience along. You don't have to spoon feed them. You don't have to give them everything they ask for. But you should make sure your ending fits the themes and questions relative to the story you've been telling thus far, and that they're clear. Even the mysteries you leave should be clear. Mysteries = good. Ambiguity = not so good.