Prophet Mohammed (ﷺ) said:
When you want to go to bed, perform ablution as you do for prayer, then lie down on your right side and say:
اللَّهُمَّ أَسْلَمْتُ وَجْهِي إِلَيْكَ، وَفَوَّضْتُ أَمْرِي إِلَيْكَ، وَأَلْجَأْتُ ظَهْرِي إِلَيْكَ، رَغْبَةً وَرَهْبَةً إِلَيْكَ، لاَ مَلْجَأَ وَلاَ مَنْجَا مِنْكَ إِلاَّ إِلَيْكَ، اللَّهُمَّ آمَنْتُ بِكِتَابِكَ الَّذِي أَنْزَلْتَ، وَبِنَبِيِّكَ الَّذِي أَرْسَلْتَ
If you should die then (after reciting this) you will die on the religion of Islam (i.e., as a Muslim); and if you live till till morning you will attain good. So let these words be the last you say (before going to bed)
NOTE: In the Hadith of Sahih Muslim 7/6885 its mentioned - Then if he dies, he will have died in a state of Fitrah.