Al-Adab Al-Mufrad, Book 42, Hadith 1009 (English) ⓘ
Mu'awiya ibn Qurra said, "My father told me, 'If you sit in a gathering expecting good to come from, but then something occurs which makes you leave, say, 'Peace be upon you,' and you will share in any good that they obtain in that gathering. There are no people who sit in a gathering and then split up without Allah having been mentioned, but that it is as if they were leaving the corpse of a donkey.'"
حَدَّثَنَا مَطَرُ بْنُ الْفَضْلِ، قَالَ: حَدَّثَنَا رَوْحُ بْنُ عُبَادَةَ، قَالَ: حَدَّثَنَا بِسْطَامٌ قَالَ: سَمِعْتُ مُعَاوِيَةَ بْنَ قُرَّةَ قَالَ: قَالَ لِي أَبِي: يَا بُنَيَّ، إِنْ كُنْتَ فِي مَجْلِسٍ تَرْجُو خَيْرَهُ، فَعَجِلَتْ بِكَ حَاجَةٌ فَقُلْ: سَلاَمٌ عَلَيْكُمْ، فَإِنَّكَ تَشْرَكُهُمْ فِيمَا أَصَابُوا فِي ذَلِكَ الْمَجْلِسِ، وَمَا مِنْ قَوْمٍ يَجْلِسُونَ مَجْلِسًا فَيَتَفَرَّقُونَ عَنْهُ لَمْ يُذْكَرِ اللَّهُ، إِلاَّ كَأَنَّمَا تَفَرَّقُوا عَنْ جِيفَةِ حِمَارٍ.
also referenced under: Hadith 1009 (Reference) & Book 42, Hadith 46 (In-Book)