Surah An-Nur, ayah 28

24:28

فَإِن لَّمۡ تَجِدُواْ فِيهَآ أَحَدٗا فَلَا تَدۡخُلُوهَا حَتَّىٰ يُؤۡذَنَ لَكُمۡۖ وَإِن قِيلَ لَكُمُ ٱرۡجِعُواْ فَٱرۡجِعُواْۖ هُوَ أَزۡكَىٰ لَكُمۡۚ وَٱللَّهُ بِمَا تَعۡمَلُونَ عَلِيمٞ ٢٨

Fa il lam tajidū fīhā ahadan falā tadkhulūhā hattā yu'dhana lakum wa in qīla lakumurji'ū farji'ū huwa azkā lakum wallāhu bimā ta'malūna 'alīm

And if you do not find anyone therein, do not enter them until permission has been given you. And if it is said to you, "Go back,"986 then go back; it is purer for you. And Allāh is Knowing of what you do.

Footnotes

986 Or a similar expression showing that the occupants are not prepared to receive visitors (which should be respected).