Likewise, Imam Muslim reported in his Sahih on the authority of `Abdullah ibn `Umar (may Allah be pleased with them) that he commanded a person that as he went to bed, he should say:" O Allah, You created myself and it is for You to take it to its ultimate goal. And its death and life is due to You, and if You give it life, safeguard it; and if You bring death, grant it pardon. O Allah, I beg of You safety." A person said to him: Did you hear it from `Umar? Thereupon he said: (I have heard from one) who is better than `Umar, viz. from Allah's Messenger (may peace be upon him). Sahih Muslim (No. 2712).
These Hadiths contain a clear indication that the soul of a human being is in the hand of Allah (Glory be to Him) because He created it from nothing and created it after it had been nothing. It is due to Allah (Glory be to Him) to keep it when a person sleeps and becomes dead and if He wills, He will let it go and bring a person back to life. Therefore, the Prophet said: "Its life and death is due to you." Meaning that it is all in Your Hand and under Your Control and none is able to do it except You, for You are the one who gives life and causes death, and You are Able on everything.
Therefore, it was legislated for a Muslim in this situation to ask his Lord to protect him if He destines life for him and asking Him for mercy and forgiveness if He destines death for him. It was reported in the Hadith of Abu Hurayrah the he said: "In amsakta nafsy farhamha (if You keep myself, show mercy to it) wa in arsaltaha fahfazha bima tahfazu bihi ibadakas-salihin (and when You let it go, protect it as You protect Your Righteous Servants)." and in the Hadith of Ibn `Umar, he said: "If You give it life, safeguard it; and if You bring death, grant it pardon."
As a Muslim should remember his final destination when he goes to sleep, he should remember the bounty and the grace of Allah on him such as food, drink, home, and good health so as to thank Him for all these bounties.
Therefore, it was authentically reported in Sahih Muslim on the authority of Anas ibn Malik (may Allah be pleased with him) that the Messenger of Allah (peace be upon him) used to supplicate when he went to bed at night saying: "Al Hamdu lillah-illadhi at`amana wa saqana, wa kafana wa awana, fakam mimman la kafiya lahu wa la mu'wiya (Praise is due to Allah Who has fed us, provided us drink, satisfied us and gave us protection. Many are those who have no one to provide for them, or give them shelter).'' Reported by Muslim (No. 2715).
Therefore, when a Muslim goes to bed, he should remember two matters: First, the past days of his life to thank Allah for and the bounties which Allah granted him in this life, such as: Good health, food, drink, home, and so on. Second, the coming times. So, he is between two matters: Either his soul is taken, then he asks Allah for forgiveness and mercy or to expand in his life span, so a Muslim in this case asks Allah to protect his soul as He protects His Righteous Servants.