Jim Carrey figures out that he wrote the book, which was just a suicide note gone awry after he killed his college fuck buddy in a fit of rage (she sliced him with a knife, called him a pussy like his dead father and fucked around his back with her psych teacher - who he frames for her murder). He jumps off a building, but just gets amnesia and goes to a mental hospital where he is all fixed up. After he is released, he meets his now current wife (omg lol!). Despite the fact that his wife and their family friend have moved the remains of the girl he killed, and seem to be cool with him as a psychotic dude that once killed a chick, he turns himself in to the police so that the psych teacher that was framed could be released from jail.
The movie ends with him in jail, awaiting sentencing, talking and laughing with his family lol