In Hamlet, act 3, scene 3, Hamlet sees Claudius praying and considers killing him immediately. Claudius is on his knees, unwary and defenseless, meaning that it would be easy to do so. However, Hamlet hesitates because Claudius is in the process of confessing his sins and cleansing his soul. Hamlet thinks that if he kills the king now, Claudius will go straight to heaven, since he has no unabsolved sins on his conscience.
Hamlet reflects that to kill Claudius at such a time would essentially be to do him a favor rather than to take revenge. Claudius showed no consideration for Hamlet's father when he murdered him "With all his crimes broad blown, as flush as May." Hamlet must therefore ensure that he kills Claudius
When he is drunk asleep, or in his rage,
Or in the incestuous pleasure of his bed;
At gaming, swearing, or about some act
That has no relish of salvation in't.
If he does so, then Claudius will be in the midst of his sins at the point of death and will go to hell.
It is difficult to discern how serious Hamlet is in offering this reason for refusing to kill Claudius at prayer. It may be yet another excuse for his delay or for his chivalrous unwillingness to stab a defenseless man in the back. From a Christian perspective, however, Hamlet's reasoning is understandable: he has recently received proof of the afterlife and of what happens to those who die with their sins unabsolved, in the form of his father's ghost.