It is narrated from Hazrat Abu Huraira (may Allah be pleased with him) that the Prophet (peace and blessings be upon him) said: "When any one of you arrives at a gathering, he should greet with salam, and when he wishes to leave the gathering, he should also greet with salam. The first occasion does not have more right than the second."
Hadith Referenceمسند احمد / مسند المكثرين من الصحابة / 7142