Ibn al-Qayyim said, ‘Avoid those things that necessitate the punishment of the grave.
And from the most beneficial of them is that when a man wants to sleep, he sits for an hour, for the Sake of Allaah, calling himself to account over the things that he has lost and gained during that day of his. Then, between him and his Lord, he renews his sincere repentance over those things that he lost, and sleeps on that repentance, firmly resolving not to return to the sin when he wakes up–and he does this every night.
So if he dies on that night of his, he would have died upon repentance and if he wakes up, he will wake up going towards action, pleased with the postponement of his appointed time so that he can turn to his Lord and set right what he missed out on.
And there is nothing more beneficial for the servant than this sleep, especially when he follows that [i.e., his resolve to renew his repentance] up with the remembrance of Allaah, performing those sunnahs which have been reported from the Prophet of Allaah when going to bed, [doing so] until sleep overtakes him.
So whoever Allaah wishes good for, He will grant him the success to do that. And there is neither movement, nor power except through Allaah.”