It is desirable that righteous people visit patients on their deathbeds and remember Allah.
Umm Salamah reported: “Allah’s Messenger, peace be upon him, said, ‘When you visit someone who is ill or is dying, say good things about him. Indeed, the angels (present there) say “amen” to whatever you utter’.” She added:”When Abu Salamah passed away, I went to the Prophet, peace be upon him, and said, ‘Oh Messenger of Allah! Indeed, Abu Salamah has died.’ The Prophet said: ‘Say: “O Allah! Forgive me and him. Give me in his place a better substitute”.’ So, I did so and Allah gave me someone better than he. He gave me Muhammad, peace be upon him.” (Recorded by Ahmad, Muslim, and the five compilers of the sunan)
In another report she said: “The Messenger of Allah, peace be upon him, came to see Abu Salamah when his sight had become fixed (he had passed away). So the Prophet, peace be upon him, closed his eyes and said: ‘When the soul is seized and it leaves the body, the sight follows it.’ Some of Abu Salamah’s family wept and wailed, whereupon the Prophet, peace be upon him, said: ‘Supplicate to Allah only to seek good for yourselves, because the angels (who are present) say “amen” to whatever you utter.’ Then he said: ‘O Allah! Forgive Abu Salamah; raise his station among (Your) rightly guided servants; and take good care of his family that he has left behind. O Lord of the Worlds ! Forgive him and us, make his grave spacious, and put light therein for him.” (Muslim)