´It was narrated that Abu Sha'tha said:` "We were sitting in the mosque with Abu Hurairah when the Mu'adh-dhin called the Adhan. A man got up and walked out of the mosque, and Abu Hurairah followed him with his gaze until he left the mosque. Then Abu Hurairah said: "This man has disobeyed Abul-Qasim.'"
Hadith Referenceسنن ابن ماجه / كتاب الأذان والسنة فيه / 733
Hadith Gradingالألبانی:صحيح | زبیر علی زئی:صحيح مسلم
1؎: Those who remained in the mosque until the prayer was completed obeyed the command of the Prophet (sallallahu alayhi wa sallam). The statement of the Prophet (sallallahu alayhi wa sallam) is that when the call to prayer (adhan) is given in the mosque, then one should not leave without performing the prayer. If a person is the imam of another place and there is a severe necessity, then it is permissible for him to leave; however, it is better that he performs the prayer before leaving. According to the hadith scholars (muhaddithin), it is permissible for a person to perform the prayer in congregation, and then in the same prayer, lead others as imam. Mu'adh (radi Allahu anhu) used to do this: his first congregational prayer would be obligatory (fard), and the second prayer in which he led others as imam would be voluntary (nafl), while the followers (muqtadis) behind him would be performing their obligatory prayer.
Explanation & Benefits
Maulana Ataullah Sajid
Commentary: It is prohibited to leave the mosque after the call to prayer (adhan) without a valid excuse; however, if there is a reasonable excuse, then there is allowance.
Source: Commentary on Sunan Ibn Mājah by Mawlānā ‘Atā’ullāh Sājid, Page: 733