Zohar Chaye Sarah
‘and Abraham went in’ (Genesis 23:2) is the aspect of the soul and to ‘mourn for Sarah’ is the aspect of the body.
“אַךְ-בְּשָׂרוֹ, עָלָיו יִכְאָב; וְנַפְשׁוֹ, עָלָיו תֶּאֱבָל”
“But his body pains him, And his soul mourns on him””
When the soul leaves the body, for the next seven days it stays close to it and mourn its separation from the body.
“יָבוֹא שָׁלוֹם, יָנוּחוּ עַל-מִשְׁכְּבוֹתָם; הֹלֵךְ, נְכֹחוֹ”
“He enters into peace; They rest in their beds, Each one who walked straightforward.”
‘walked straightforward’ means that the soul goes to its place in heaven.
This verse from Job reveals that when a righteous dies he goes into state of peace, the body goes into rest and his soul goes to his place in heavens.
Rabbi Yitzchak says that when the soul has merits, it goes up to its reserved level in heavens and the body lies down, resting in peace. When the soul has no merits, the ‘punishment’ process starts and the soul wonders, visiting its grave everyday, experiencing the pain of leaving this world without enough merits to move up.