By praying to God, Claudius is setting the truth free. He knows what he did was wrong, but still committed with his actions. Hamlet is beyond furious when he hears what he has known all along. Claudius is also being set free because we, the readers, foreshadow that Hamlet is going to kill him. Hamlet just has to wait for the right moment when Claudius is not in touch with God.
Just so we're all clear, it's okay to miss people you no longer want in your life. But I never actually said I didn't want you in my life. You just threw it out the window like it was nothing to begin with. So I just held the door open and let you go.