Umm Salama bint Abu Umaya reported,

The Messenger of Allah ﷺ said, "When you are present with someone who is sick or dying, speak only good words, for the angels say 'Amen' to whatever you say."When Abu Salama died, I went to the Prophet ﷺ and said, "Messenger of Allah, Abu Salama has died."He said, "Say, 'O Allah, forgive me and him, and grant me a good successor in his place.'"She said, "I did so, and Allah granted me one better than him, Muhammad the Messenger of Allah ﷺ."

Ibn Majah 1447

Sahih

حدثنا أبو بكر بن أبي شيبة وعلي بن محمد قالا حدثنا أبو معاوية عن الأعمش عن شقيق

عن أم سلمة قالت

قال رسول الله ﷺ إذا حضرتم المريض أو الميت فقولوا خيرا فإن الملائكة يؤمنون على ما تقولون فلما مات أبو سلمة أتيت النبي ﷺ فقلت يا رسول الله إن أبا سلمة قد مات قال قولي اللهم اغفر لي وله وأعقبني منه عقبى حسنة قالت ففعلت فأعقبني الله من هو خير منه محمد رسول الله ﷺ

ابن ماجه 1447صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Funerals
Chapter
What is said in the presence of the sick when death approaches
Numbering
Darussalam 1447
Ibn Majah 1447