The Messenger of Allah ﷺ said, "When one of you arrives at a gathering, let him give the greeting of peace, and when he wishes to leave, let him give the greeting of peace. The first is no more deserving than the last."
حدثنا بشر عن ابن عجلان عن سعيد المقبري
قال رسول الله ﷺ إذا انتهى أحدكم إلى المجلس فليسلم فإذا أراد أن يقوم فليسلم فليس الأول بأحق من الآخر
Its isnad is sahih. It will come with two isnads from Ibn Ajlan, 7390 and 9662. Abu Dawud also narrated it, 520:4/5208 Awn al-Mabud, from Ahmad bin Hanbal and Musaddad, from Bishr bin Mufaddal, with this isnad. Tirmidhi narrated it, 389, by way of Layth bin Saad, from Ibn Ajlan. Tirmidhi said, this hadith is hasan. This hadith has also been narrated from Ibn Ajlan, from Saeed Maqburi, from his father, from Abu Hurairah, from the Prophet.Bukhari narrated it in Adab al-Mufrad, page 148, with two isnads from Ibn Ajlan, with this wording. He also narrated it between them, from Ibn Muthanna, from Safwan bin Isa, from Ibn Ajlan, from Saeed Maqburi, from his father, from Abu Hurairah. This is the version that Tirmidhi pointed to. Bukhari also narrated it in Adab al-Mufrad, page 145, at length as part of a story, by way of Yaqub bin Zayd Taymi, from Saeed Maqburi, from Abu Hurairah, and its isnad is also sahih.Suyuti attributed it in Jami Saghir, 497, also to Ibn Hibban and Hakim.