It's Sunnah to close and lock windows and doors after sunset.
Is there a set time after sunset when it becomes ok within the Sunnah to re-open them?
Islam Stack Exchange is a question and answer site for Muslims, experts in Islam, and those interested in learning more about Islam. It only takes a minute to sign up.Sign up to join this community
The apparent meaning of this hadith is that you keep the doors closed for the whole night and open it when needed in the morning. The purpose is to prevent pests and devils who roam in the night from entering the house and causing damage.
وقال ابن العربي: ظن قوم أن الأمر بغلق الأبواب عام في الأوقات كلها، وليس كذلك، وإنما هو مقيد بالليل
Ibn al-‘Arabi said: Some people think that the command to close doors is general and is applicable to all times, but that is not the case. Rather it is limited to the night.