Now might I do it pat, now he is praying;
And now I'll do't. And so he goes to heaven,
And so am I revenged. (3.3.76-78)
In these opening lines of his famous speech in act 3, scene 3 of Shakespeare's Hamlet, Hamlet is contemplating Claudius's fate in the afterlife. "And so he goes to heaven" is a statement that reflects a widely-held belief during the Elizabethan period that a person's salvation or damnation (whether they go to heaven or to hell) is determined not by a "final judgment" of a person's behavior over the entirety of their life but solely by their state of mind in the final moments before their death.
Hamlet makes two references to this belief in this speech. One reference is in the lines cited above, and the later reference is to his own father's death, which he is now certain came at the hands of Claudius:
HAMLET. He took my father grossly, full of bread,
With all his crimes broad blown, as flush as May;
And how his audit stands, who knows save heaven? (3.3.82-84)
Hamlet's father was killed while he was sleeping, before he had a chance to repent his sins—for which he is now being punished in the afterlife. When Hamlet sees Claudius, he appears to be in the act of "the purging of his soul" and repenting of his sins at that very moment. If he kills Claudius now, Hamlet believes his soul will be sent to heaven.
It's not enough for Hamlet simply to kill Claudius for murdering his father. To rightly and fully avenge his father's death, Hamlet must ensure that Claudius's soul suffers as his father's soul suffers.
Thus, what seems at first to be another example of Hamlet's indecision and inaction could also be interpreted as very prudent behavior. Hamlet decides not to kill Claudius at that moment, but to wait until Claudius "is drunk asleep; or in his rage; / Or in the incestuous pleasure of his bed; / At game, a-swearing, or about some act / That has no relish of salvation in't" (3.3.91-94). In other words, Hamlet wants to kill Claudius when he's sinning, and send his soul straight to hell.