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 hasan] Tirmidhi recorded it, Isti'dhan, Chapter on what has been said regarding the salam upon standing and upon sitting, h: 2706, from the hadith of Muhammad bin Ajlan, with the same wording, and he explicitly stated the hearing in Bukhari's Adab al-Mufrad, h: 1008. Tirmidhi said, Hasan.