There are two timelines in the film.
The first timeline covers the beginning of the film and the very end of the movie. Timeline two begins when Donnie is drawn out of the comfort of his home by the hallucinations and ends at the moment when the horrific plane crash occurs.
In order to understand the film clearly we must distinguish and separate the two timelines. In the first timeline, Donnie was in his room for the crash. In the second, he had left the house, therefore everything that happened after was inside of the second timeline. This includes the incidents whereby Donnie finds himself responsible for the deaths of his Girlfriend and the man who ran his girlfriend over, two horrible events for Donnie to deal with.
These events form Frank, the monster who is a product of such events. Donnie realises after killing Frank that the only way for these events to not have occured is for him to have died from the plane crash so timeline 2 never occurs. The monster that was created needs to be uncreated.
This is the reasons for Donnie trying and finally succeeding in using time travel powers to go back in time and die as a result of the . This in turn saves Donnie from feeling responsible for the horrific events of timeline 2. Donnie laughs upon this reality becoming clear in his consious that dieing prevents such occurances and that there is irony in death saving him.