Repetition is crucial in any movie because it sets up the final scene. If your final scene comes out of nowhere, then it will be unsatisfying because it will feel forced and phony. To set up your final scene, you must repeat the final scene in different ways so when the final scene does occur, the previous scene will have prepared us for it.
In “Hello, My Name is Doris,” the hero is an old lady who falls in love with a young man at work. Each time she runs into him at work, she fantasizes about making love to him. Then the final scene shows her fantasizing about him once more, but it’s suddenly cut off, making us wonder if what we just saw was real or another one of her fantasies. This ending makes the story feel complete and whole.
“Harold and Maude” is another movie that repeats the ending when the hero constantly fakes suicide. Then in the end, we wonder if he really will kill himself when the woman he loves commits suicide.
The final scene must be foreshadowed somewhere earlier in the story. In “Avatar,” the hero finally merges with his avatar body, but this merging process was set up earlier when a scientists is shot and lays dying so the aliens try to merge her soul into her avatar body before her human body dies. This sets up the final scene when the hero decides to merge with his avatar body so he can forever be with his girlfriend.
In “Star Wars,” the final scene where Luke blows up the Death Star is foreshadowed by his ability to block a user beam with a light saber while blindfolded.
Watch a mediocre movie with an unsatisfying ending and it’s likely because it wasn’t set up earlier. Watch a great movie and you’ll see that the ending is set up earlier.