Hamlet's musings on suicide, especially the "to be or not to be" speech, are legendary and continue to direct discussions of the value of life and the mystery of death. But Hamlet himself never commits suicide. It is Ophelia, who never mentions the possibility of taking her own life, who drowns, seemingly as a result of some combination of madness and despair. Death threads its way through the entirety of Hamlet, from the opening scene's confrontation with a dead man's ghost to the bloodbath of the final scene, which leaves almost every main character dead. Hamlet constantly contemplates death from many angles. He is both seduced and repelled by the idea of suicide, but, in the famous gravedigger scene, he is also fascinated by the physical reality of death. In a way, Hamlet can be viewed as extended dialogue between Hamlet and death.
The fact that Hamlet is still talking about suicide even after he has sworn to avenge his father shows that the Prince's problems lie much deeper than simple grief over his father's murder.
Hamlet's anger against his mother is rooted in the fear that if someone's life can be so easily forgotten after death, life itself has no meaning. His crisis is therefore an existential one, not one of morality.