Toward the end of his life, whenever the Messenger of Allah ﷺ wanted to rise from a gathering, he would say, "Glory be to You, Allah, and praise be to You. I bear witness that there is no god but You. I seek Your forgiveness and turn to You in repentance."A man said, "Messenger of Allah, you say words now that you did not say before."He replied, "It is an expiation for whatever happens in the gathering."
حدثنا محمد بن حاتم الجرجرائي وعثمان بن أبي شيبة المعنى أن عبدة بن سليمان أخبرهم عن الحجاج بن دينار عن أبي هاشم عن أبي العالية
كان رسول الله ﷺ يقول بأخرة إذا أراد أن يقوم من المجلس سبحانك اللهم وبحمدك أشهد أن لا إله إلا أنت أستغفرك وأتوب إليك فقال رجل يا رسول الله إنك لتقول قولا ما كنت تقوله فيما مضى فقال كفارة لما يكون في المجلس
[Its chain is hasan] Ahmad narrated it: 4/425, Nasai in Al-Kubra, no. 10259, and Amal al-Yawm wal-Layla, no. 426, and Darimi, no. 2661, from the hadith of Hajjaj bin Dinar with the same chain. The hadith has many routes. Abu Hashim is Yahya bin Dinar Rumani.