The Number 23 (2007) ending / spoiler
Walter (Jim Carrey) wrote the book and he's the one who killed Laura Tollins. He killed her because of his obsession with the number 23 after he found out she was cheating on him with the professor (Kyle). Walter became obsessed with the number years ago when he saw it scribbled on paper after he witnessed his father kill himself. Kyle was imprisoned for the murder because he got his fingerprints on the murder weapon when he walked in the room. After Walter buried Laura, he checked into the hotel and started writing a suicide note and the note became the book because of his obsession with the number. The 23rd and last chapter (his confession that he killed Laura) he wrote it on one of the walls of the hotel room. After that he jumped from the window to kill himself and survived. Because of an injury to his head, Walter forgot about the murder and writing the book. He recovered from his injuries in the psychiatric hospital where his wife Agatha (in the present day) found the box with his belongings (the first copy of the novel, the saxophone, the detective novels, etc.). At the psychiatric institute the book was dismissed by the doctors as fantasy and later on one of the doctors (the one who visited the post office) became obsessed with the number 23 after publishing and reading the book. Walter and Agatha (Virginia Madsen) met as he was leaving the hospital after completing physical therapy. In the present day, after Walter remembers everything, Agatha tells Walter that she loves him and that he's not a killer but a sick person that got better. Walter is about to kill himself by standing in front of an incoming bus but moves away at the last minute. He narrates that life is all about making choices and that there's no such thing as destiny. Walter turns himself in for the murder, Laura is given a proper funeral and Kyle is released from prison. Walter also mentions that it's a matter of time for him to be on parole and that time is just a counting system and numbers with meaning attached. The last scene is Walter's wife and his son Robin visiting him in prison and Walter looking at the clock which reads 2:15 (23). Before the credits, there's a quote from the Bible (Numbers: chapter 23, verse 32) that says: "Be sure that your sins will find you out."
Submitted by Racer X