Write an outline of the story before you write the story itself. Use this to guide your writing, but be flexible and allow for changes you may wish to make as you write.
Prepare a character sketch of all the major characters. Write an especially detailed sketch of the main character and ensure you know what she wants more than anything else in the world. This will be her goal in the story.
Recall the beginning of a narrative story when you prepare to write the ending. Recall the initial disruption to the main character's life and what goal he subsequently pursued.
Review the obstacles the main character met along the way, and other characters that became important to both the main character and the story.
Write the only ending possible for this character -- be it happy or tragic. Make sure you understand why you chose this type of ending, that it fits the theme of your story and supports your underlying points.