Al-Bara' bin `Azib (May Allah be pleased with them) said:
Messenger of Allah (SAWS) asked me to recite whenever I go to bed:
"Allahumma aslamtu nafsi ilaika, wa wajjahtu wajhi ilaika, wa fawwadtu amri ilaika, wal-ja'tu zahri ilaika, raghbatan wa rahbatan ilaika, la malja wa la manja minka illa ilaika. Amantu bikitabikal-ladhi anzalta, wa nabiyyikal-ladhi arsalta
(O Allah! I have submitted myself to You, I have turned my face to You, entrusted my affairs to You; and committed my back to You out of desire for You and fear of You; expecting Your reward and fearing Your punishment. There is no refuge and no place of safety from You but with You. I believe in the Book You have revealed and in the Prophet You have sent.)''
Messenger of Allah (SAWS) that if anyone recited these words and died that night, he would die in the true religion. In case he remains alive till morning, he will obtain good.
[Al-Bukhari and Muslim]
In another narration: He reported Messenger of Allah (SAWS) as saying: "If you go to bed, perform the Salat Wudu', lie down on your right side and say [the above Du`a (supplication)] and let these words be your last".
Commentary: It is better to make Wudu' before going to sleep. Similarly, it is also meritorious to recite the invocation mentioned in the Hadith before one goes to bed, because it is a prayer for the renewal of Islam and Faith and request for grant of peace and security.