Ending may be the most important part of a story but inevitably you find out that with a certain plot you don’t have to plan too far ahead. What you should do with the characters, good or bad, and will it all end up in laughter or in tears. You just write it down, trying not to squeeze out too much toothpaste at once.
Good plot takes care of the ending. That is one of the most fascinating things about writing fiction.