Now, once the middleof the book comes to an end, the time has come to reach the end. The writer can't just write "The End". There are scenes that lead up to the chance to write these words.
A point is reached where the hero, heroine and maybe even the villain realizes if they're not careful they will lose everything. They do something and slide into the Black Moment where they believe they have lost all. If the story ends here, the ending would be bitter so more is needed.
After this comes the decision to try one more time. The hero, heroine or villain must reach this decision to move forward. They will do what needs to be done to reach their goal. Now the story could end here but that might leave the reader on the edge of a cliff and never know what happens. A master story teller or someone writing serials ends a story this way but readers want to watch the lead character suffer, change and reach an ending.
As to the ending, the main character can win, lose or compromise in the final scene but what happens must be satisfactory. This ending either happy or sad must let the reader know the story has ended the right way. Though not always for there are some readers who realize the ending is right for the book but they want the ending to be different.