Thinking that he would die soon, the man confessed. He thought that he won't be facing the consequences of his actions here if he confessed not; I think the thought of punishment in the afterlife drove him to confess, so he sought forgiveness before he dies.
Can you blame a man who doesn't have the balls to face the consequences of his actions, in this life or the next? He's just looking for an escape. Nothing more.