During sleep, our souls depart from our bodies in an obscure manner. The soul of every sleeping person is held by Allaah, and He then releases it when it is time to wake up. This is expressed by texts from both the Qur'aan and the Sunnah.
Allaah سبحانه و تعالى says,
And Allaah سبحانه و تعالى says,
Commenting on this aayah, Imaam al-Qurtubi رحمه الله said: "Allaah سبحانه و تعالى takes away the soul at the end of a person's term, as well as those in sleep... Thus, He holds the souls for which death has arrived, and releases the other souls until the time of their death... Ibn 'Abbaas رضي الله عنهما and others said, 'The souls of the living and of the dead meet during sleep and get acquainted as Allaah سبحانه و تعالى wills. When they later wish to return to the bodies, Allaah سبحانه و تعالى keeps with Him the souls of the dead, and sends the souls of the living back to their bodies.' Al-Qushayri Abu Nasr رحمه الله said, 'Allaah سبحانه و تعالى takes the souls in the states of sleep and death. He then restricts the actions of those in the state of sleep, and keeps those in the state of death until Resurrection Day.' Allaah سبحانه و تعالى takes the souls during sleep by (temporarily) removing their feelings and replacing perception with unawareness. And He takes them at death by completely removing perception." 
Shaykh Muhammad Ibn Saalih al-'Uthaymeen رحمه الله said, "When a person goes to sleep, Allaah سبحانه و تعالى takes away his soul in a form of minor death during which the soul goes to wherever Allaah سبحانه و تعالى wills." 
Among the sleep-time adhkaar taught by the Prophet صلى الله عليه وسلم is:
"With Your Name, my Lord, I lay down my side, and by You (i.e. Your permission and help) I raise it. If You hold my soul (by death), show it mercy, and if You release it (i.e. keep it alive) then protect it as You protect Yoru righteous servants." 
Similarly, the Prophet صلى الله عليه وسلم recommended saying before going to sleep: "O Allaah, You created my soul, and You take it away. You decide its (i.e. my) death and living. If You keep it alive, safeguard it, and if You make it die, forgive it." 
And the Prophet صلى الله عليه وسلم used to say when he woke up: "Praise be to Allaah who resurrected us after He made us die. And to Him will be the (people's) emergence (from the graves)." 
And the Prophet recommended saying upon waking up: "Praise be to Allaah who granted me well-being in my body, returned my soul to me, and permitted me to extoll Him." 
Referring to sleep, Abu Qataadah رضي الله عنه reported that the Prophet صلى الله عليه وسلم said: "Indeed, Allaah took away our souls (during sleep) when He willed, and returned them to us when He willed." 
We learn from the above texts that sleep is a minor death in which the soul leaves the body by Allaah's will and control سبحانه و تعالى. This was further confirmed by the Prophet صلى الله عليه وسلم when he negated both forms of death for the people of Jannah. Jaabir رضي الله عنه and 'Abdullaah Ibn Awfaa رضي الله عنه reported that the Prophet صلى الله عليه وسلم said: "Sleep is the brother of death. And the people of Jannah do not sleep." 
During the 'minor death', a soul gets to meet other souls of both living and dead people. Khuzaymah رضي الله عنه reported that he had a dream that he was prostrating upon the Prophet's forehead صلى الله عليه وسلم. When he told this to the Prophet صلى الله عليه وسلم, the Prophet صلى الله عليه وسلم leaned back and said: "Indeed, a soul surely meets another soul (during sleep). Confirm your dream: sit and prostrate and do as you did in the dream." 
Seeing specific individuals during sleep normally means that Allaah سبحانه و تعالى has created their resemblance in the dreamer's mind. However, there are times when the dreamer's soul actually meets other souls of living or dead people. Its interaction with these souls may remain imprinted in the dreamer's mind after awakening. There is no indication that the other souls would remember the encounter, especially because the Prophet صلى الله عليه وسلم did not indicate remembering encountering Khuzaymah's soul رضي الله عنه. The encounter of souls is an obscure matter of ghayb, and cannot be subjected to out worldly standards. 
We should note that the above texts indicate that a person's soul travels very fast so as to meet other souls, angels, etc. Even if he sleeps for just a brief moment, his soul is taken and then returned to his body during that moment. Since the soul and its actions are affairs of ghaybwhich cannot be subjected to the laws of this world, the only correct approach is to accept and believe in all of the information about them that is based on authentic texts.
Allaah سبحانه و تعالى sends the soul during sleep on a mysterious journey that involves amazing visions and encounters. As for the souls whose term in this life has not yet ended, Allaah سبحانه و تعالى sends them back to their bodies. These released souls may then remember and relate some of what they experience during their journey (i.e. dreams)."