The ending of a story doesn't necessarily have to be happy but it has to make sense in a way that ties up what has happened.
There are different types of story endings, for example:
The cliff-hanger - this isn’t an ending as such, it’s a way of tempting the reader to read the next chapter or instalment. Charles Dickens wrote his chapters like this as they were originally published in magazines in serial form. For example, does the spy manage to stop the bomb in time?
The twist-in-the-tale - the reader will feel fairly sure about the ending, but in the final part everything changes and we are surprised. For example, we learn that it isn’t a bomb after all, it’s a birthday present!
The enigma ending - the story stops, but the reader is left a little unsure what will come to happen, yet is intrigued by the possibilities - and still feels satisfied. For example, the bomb is defused and everyone is safe, but then an army commander reports the theft of another bomb... only this time twice as powerful.
There are many possibilities; but there are two endings you should try to avoid:
The trick ending - a bomb will inevitably explode and as it does, the narrator wakes up - it was all a dream. This is too clichéd and unsatisfying for modern readers.
The disconnected ending - the secret agent suddenly stops worrying about the bomb, retires, and goes off to play golf. Readers don't like this because the ending has nothing to do with the story – very unsatisfying.
Whatever kind of story you write, work out a satisfying ending and include it in your plan.
Remember, writing that is creative and imaginative needs to be entertaining. You need to experiment a little and not be frightened to try something new.