Asking Permission to leave when They are doing something together

This is another matter of etiquette to which Allah has guided His believing servants. Just as He commanded them to seek permission when entering, He also commanded them to seek permission when leaving, especially when they are doing something together with the Messenger ﷺ, such as the Friday, `Id, or congregational prayers, or a meeting for the purpose of consultation and so on. Allah commanded them not to leave him in these situations until they had asked his permission. If they did this, then they were of the true believers. Then Allah commanded His Messenger to give permission when someone asked for it, if he wanted to. He said:

فَأْذَن لِّمَن شِئْتَ مِنْهُمْ وَاسْتَغْفِرْ لَهُمُ اللَّهَ

(give permission to whom you will of them, and ask Allah for their forgiveness.)Abu Dawud reported that Abu Hurayrah said, "The Messenger of Allah ﷺ said:

«إِذَا انْتَهَى أَحَدُكُمْ إِلَى الْمَجْلِسِ فَلْيُسَلِّمْ، فَإِذَا أَرَادَ أَنْ يَقُومَ فَلْيُسَلِّمْ، فَلَيْسَتِ الْأُولَى بِأَحَقَّ مِنَ الْآخِرَةِ»

(When any of you joins a gathering, let him say Salam, and when he wants to leave, let him say Salam. The former is not more important than the latter.) This was also recorded by At-Tirmidhi and An-Nasa'i; At-Tirmidhi said: "It is a Hasan Hadith."