First: know where you’re going. Even if you don’t have an outline, have a plan in mind. It helps give the characters a sense of purpose. When you get about half-way done with your book, reevaluate where your characters are, and how they got there. Then, ask yourself what the next steps are.
Second: Leave your characters options. Of course, you want to create conflict and take options away, but they should still have SOME option. Something that will allow them to emerge victoriously. If they have no options, your ending will be forced into the dreaded Deus ex Machina!
Third: What loose threads do you have running through your work? Sometimes, simply evaluating what you’ve already done will really help you write toward the future, toward the inevitable end. Is there a way you can tie up one thread with another? Can you have the character change at the critical time, just as he defeats the villain and wins the heart of his true love? The more closely these things can happen, the more powerful your ending will be.
Fourth: Try to find something unexpected, but inevitable. Flannery O’Connor talks a lot about this. And while it sounds tough to do, it’s still possible. The way you can do it is to present the obvious solution, and then give reasons that might prevent that solution from occurring. For example, in order for your character to defeat the bad guy, he must abandon his faithful traveling companion. The characters recognize this early on, but proceed as if they can find another way. Let them find hope that another opportunity for victory exists. If you take away this new hope, all that’s left is the first option. And while not ideal for your characters, it can have a profound impact on your readers.
But you’re stuck, you say? You’ve written yourself into a corner and left your characters no option? Again—evaluate. What do they have. List their assets. Then find a way to link them together to find a solution. Or ask yourself what they need to emerge victoriously, then go back and add that into the flow of the story somewhere. Another solution to the “stuck” problem is to write the dreaded Deus ex Machina, and then go back and foreshadow it enough so that it feels natural, so that it feels right. This is not the best option, but it is still an option. Astute readers will be able to pick out when you do this.
Tricky as they are, endings give you a great opportunity for profound emotional impact on the reader. Treat endings with the time, care, and respect they demand, and your readers will thank you.