The Zohar advises us to make special preparation for the night sleep and explains. At night the bad side and death of the Tree of Knowledge are in control. When we go to sleep we experience the aspect of death and our souls ascend to the upper level for rest and protection. The Zohar suggests getting ready and submitting our souls to the Light before we fall asleep. Out of 60 parts, 59 parts go up and one stays with the body to sustain a state of life for the body.
While we are sleeping, we want to reach the highest spiritual level and enjoy maximum soul rest and ‘recharge’. For that we need to cleanse our souls before they leave the body. We do that by meditating and confessing on our actions, forgiving everyone that had an issue with us without any reservations. That includes correction issues from previous lives. In our minds, we should be ready to accept all four types of death. It helps remove judgment after we fall asleep and if our time has arrive to return our souls to the Creator then we are ready for it.
After this confession and meditation, we recite the Shema Israel prayer and the Ana B’Koach. Then we say the verse from Psalms 102:14 “אַתָּה תָקוּם תְּרַחֵם צִיּוֹן כִּי עֵת לְחֶנְנָהּ כִּי בָא מוֹעֵד.” “You will arise and have pity on Zion; it is the time to favor her; the appointed time has come.” With these words we ask God to bring the Light to Yessod of Malchut and bring redemption the entire world. The last words are the words of the verse from Psalms 31:6 “בְּיָדְךָ אַפְקִיד רוּחִי פָּדִיתָה אוֹתִי יְהוָה אֵל אֱמֶת” – ”Into your hand I commit my soul; you have redeemed me, O YHVH, God of truth”. After these words we should not say other words because it may break the vessel we just created or disconnect us from the Light we want to achieve.
You may find some different and expanded versions of the prayers before going to bed but the main elements are described above.