Abu Hurairah reported,

The Messenger of Allah ﷺ said, "Whoever sits in a gathering in which much idle talk takes place, then before rising from that gathering says, 'Glory be to You, O 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,' Allah will forgive him for whatever occurred in that gathering."

Tirmidhi 3433

Sahih

حدثنا أبو عبيدة بن أبي السفر الكوفي واسمه أحمد بن عبد الله الهمداني حدثنا الحجاج بن محمد قال قال ابن جريج أخبرني موسى بن عقبة عن سهيل بن أبي صالح عن أبيه

عن أبي هريرة قال

قال رسول الله ﷺ من جلس في مجلس فكثر فيه لغطه فقال قبل أن يقوم من مجلسه ذلك سبحانك اللهم وبحمدك أشهد أن لا إله إلا أنت أستغفرك وأتوب إليك إلا غفر له ما كان في مجلسه ذلك

الترمذي 3433صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami Tirmidhi
Book
Supplications
Chapter
What to say when getting up from a gathering
Numbering
Darussalam 3433
Tirmidhi 3433