Rakhiya De Shabad (ਰਖਿਆ ਦੇ ਸ਼ਬਦ) is a collection of Shabads (hymns) that are typically read before reciting Kirtan Sohila or any time when one feels fear. A Gursikh went to Guru Arjun Dev Jee, saying that his horses get stolen during the night time. Guru Sahib asked him whether he did full Kirtan Sohila or not? The Gursikh replied that he does but falls asleep half way. The fifth Guru gave him "Rakhiya De Shabad" and instructed him to read it before Kirtan Sohila.
That night, he completed his Rakhiya De Shabad and fell asleep after reciting Kirtan Sohilaa. As the two robbers came to get his horses, the stable doors automatically closed with them inside and would not open. The next day, as the Gursikh opened the doors from the outside without any force, the robbers fell at his feet asking forgiveness thinking that he had some special power. The Gursikh explained that he was not super and did not have any powers, but that Guru Arjun Dev jee is the doer of all. He took them to Guru Jee, who later dealt with them accordingly.
In the same way, if we finish both these prayers before sleeping, Guru Sahib will create a fort around your bed or sleeping place. You are supposed to do Rakhiya De Shabad and Kirtan Sohila facing the pillow where your head will rest, but make sure that it is not where your feet are point. Jamdooths (Angels of death) cannot touch you if you do these prayers.