We tend to think of memory the same as an audio-visual recording of the events in our life. Unfortunately, it is not. Memory captures snapshots which influence what we recall later. So a relatively good experience with a particularly bad ending can bias memory to recall the whole as bad.

If the below video does not display, then try Daniel Kahneman: The riddle of experience vs. memory.