Praise be to Allah.
What happens to our soul when we sleep?
There is clear evidence in the Quran and Sunnah which indicates that the soul is taken when one falls asleep, and that sleep is a kind of death . This evidence includes the following:
- Allah, may He be glorified and exalted, says (interpretation of the meaning):
“It is Allah Who takes away the souls at the time of their death, and those that die not during their sleep. He keeps those (souls) for which He has ordained death and sends the rest for a term appointed. Verily, in this are signs for a people who think deeply.” [Az-Zumar 39:42]
- And He, may He be glorified, says (interpretation of the meaning):
“It is He Who takes your souls by night (when you are asleep), and has knowledge of all that you have done by day.” [Al-An‘am 6:60]
- Abu Qatadah (may Allah be pleased with him) narrated that when they slept and missed the prayer, the Prophet (blessings and peace of Allah be upon him) said: “Verily Allah took your souls when He willed, and He returned them when He willed.” (Narrated by al-Bukhari, 7474)
- Abu Juhayfah (may Allah be pleased with him) said: The Messenger of Allah (blessings and peace of Allah be upon him) was on a journey during which they slept until the sun rose. He said: “Verily you were dead and Allah returned your souls to you; whoever sleeps and misses a prayer, let him offer it when he wakes up, and whoever forgets a prayer, let him offer it when he remembers.” (Narrated by Abu Ya‘la in al-Musnad, 2/192; classed as sahih by al-Albani in Irwa al-Ghalil, 1/293)
- Hudhayfah (may Allah be pleased with him) narrated that when the Prophet (blessings and peace of Allah be upon him) woke up, he would say: “Al-hamdu Lillahi alladhi ahyana ba‘da ma amatana wa ilayhi an-nushur (Praise be to Allah Who has given us life after He caused us to die, and to Him will be the resurrection).” (Narrated by al-Bukhari, 6312. It was also narrated by Muslim in his Sahih, 2711, from al-Bara (may Allah be pleased with him).
This evidence was quoted by al-Hafiz Ibn Rajab (may Allah have mercy on him), who then said:
“The verse indicates that sleep is a death, and the hadith indicates when a person sleeps his soul is taken . They both indicate that the soul that is taken in death is the soul that is taken during sleep.” (Fath al-Bari by Ibn Rajab, 3/325)
Is the soul still connected to the body during sleep?
But the taking of the soul in sleep does not necessarily mean that it is completely separated from the body, as happens in death; rather the fact that the life remains in the body during sleep indicates that the soul is still connected to the body during sleep , but the connection is less than the connection when it is awake. Not every departure of the soul from the body implies death; rather what happens to the body differs according to the type of separation.
Ibn Rajab (may Allah have mercy on him) said:
“The taking of the soul from the body does not necessarily mean that it has departed from the body altogether; rather it may be taken whilst some kind of connection is still present, as in the case of one who is sleeping.” (Fath al-Bari, by Ibn Rajab, 3/326)
For other scholarly opinions on this issue, please see al-Jami‘ li Ahkam al-Quran, by al-Qurtubi, 15/261; Fath al-Bari by Ibn Hajar, 11/114
However, what appears to us to be the case is that what you mentioned in your question does not have anything to do with this issue at all; the departure of the soul during sleep only happens when one is actually sleeping, and it does not happen before sleeping as you mention.
Perhaps what is happening to you is a psychological matter or excessive preoccupation with death and the like.
We ask Allah to keep you safe and sound and to put your affairs straight.
And Allah knows best.