In act 3, scene 2 of Shakespeare's Hamlet, the "play-within-a-play scene," Hamlet observes Claudius's reaction to the play and decides that the ghost of his father was telling the truth. Claudius murdered Hamlet's father.
Rosencrantz and Guildenstern come to Hamlet to tell him that Gertrude, Hamlet's mother, wishes to speak with him. Hamlet engages in some witty dialogue with them about a recorder, but they're interrupted by Polonius, who's also come to tell Hamlet that his mother wants to see him.
Hamlet has some nonsense dialogue with Polonius about the shape of clouds, then he sends everyone away.
HAMLET. ... 'tis now the very witching time of night,
When churchyards yawn, and hell itself breathes out
Contagion to this world. Now could I drink hot blood,
And do such bitter business as the day
Would quake to look on. (3.2.371-375)
Hamlet is on his way to his mother's rooms when he encounters Claudius on his knees, seemingly deep in prayer. Hamlet has just remarked how he could drink hot blood and that he's prepared to do whatever is necessary to avenge his father's murder.
HAMLET. Now might I do it pat, now he is praying;
And now I'll do't. (3.3.75-76)
We can imagine Hamlet quickly raising his sword over Claudius's head to bring it down through Claudius's body,or taking a preparatory backswing before plunging the blade into Claudius's back or cutting off his head.
Than Hamlet suddenly stops moving, frozen in time.
HAMLET. And so he goes to heaven... (3.3.76)
In that split second, is it possible that Hamlet suddenly realizes what he's preparing to do and realizes the consequences of his actions? But Hamlet doesn't say anything about realizing that he's about to kill a man. He spends the next twelve lines talking himself out of killing Claudius, and the following eight lines justifying his decision to himself.
Hamlet's stated reason for not wanting to kill Claudius is that he would be sending Claudius to heaven with his sins forgiven, rather than condemning Claudius's soul to hell for killing his father.
The real reason why Hamlet doesn't kill Claudius now—or at any other time in the play except in the last scene—is due to Hamlet's dual tragic flaws of indecision and inaction.
Throughout the play, Hamlet doesn't initiate any action. Hamlet only reacts to the circumstances in which he finds himself. At this moment, even with Claudius kneeling in front of him unaware and unprotected, there is nothing and no one prompting Hamlet to kill Claudius. So Hamlet does nothing, then he rationalizes his inaction to himself. Indecision and inaction are part of Hamlet's nature, part of his character, and ultimately lead to his tragic death.
What's remarkable is that at the end of this short soliloquy, after Hamlet decides to wait for a better time to kill Claudius, he simply dismisses the matter from his mind!
HAMLET. ...And that his soul may be as damn'd and black
As hell, whereto it goes. My mother stays.
This physic but prolongs thy sickly days. (3.3.96-98)