It is not permissible to leave the Masjid after hearing the Adhan except to perform Wudu', answering the call of nature, or any other necessity. It is reported that
saw a person leaving the Masjid after the Adhan. Upon this he remarked, "This (man) disobeyed Abu Al-Qasim (peace be upon him)."
Related by Muslim in his Sahih.
The same ruling applies for a person who is in a room inside the precincts of the Masjid.May Allah grant us success. May peace and blessings be upon our Prophet Muhammad, his family, and Companions.