Assalaamu Alikum Wa Rahmatullahi Wa Barakaatuh
What I know that in the book of '
Funerals (Al-Janaaiz)' of Sahih Bukhari.
Narrated Anas: The Prophet said, "When a human being is laid in his grave and his companions return and he even hears their foot steps, two angels come to him and make him sit and ask him: What did you use to say about this man, Muhammad ? He will say: I testify that he is Allah's slave and His Apostle. Then it will be said to him, 'Look at your place in the Hell-Fire. Allah has given you a place in Paradise instead of it.' " The Prophet added, "The dead person will see both his places. But a non-believer or a hypocrite will say to the angels, 'I do not know, but I used to say what the people used to say! It will be said to him, 'Neither did you know nor did you take the guidance (by reciting the Quran).' Then he will be hit with an iron hammer between his two ears, and he will cry and that cry will be heard by whatever approaches him except human beings and jinns."
and also what Uth`maan ibn ‘Affaan (may Allaah be pleased with him) said: When the Prophet (peace and blessings of Allaah be upon him) had finished burying the deceased he would stand over him and say: “Pray for forgiveness for your brother, and ask that he be made steadfast, for now he is being questioned.”
Narrated by Abu Dawood, 3221; classed as saheeh by al-Albaani in Ahkaam al-Janaa’iz, p. 198.
Standing over him means standing over his grave.
“and [said]: Pray for forgiveness for your brother” means: ask for forgiveness for him from Allaah, i.e., say: “O Allaah forgive him.”
“and ask that he be made steadfast” means: ask Allaah to make his tongue steadfast in answering the two angels, i.e., say: “O Allaah make him steadfast in speech.”
“for now he is being questioned” i.e., at that moment the two angels are coming to him, namely Munkar and Nakeer, so he is in the greatest need of prayers for forgiveness and steadfastness.
and never heard of a hadeeth mentioning the 40 steps or that the Questioning begins after the last person leaves and Allah knows the best.