It was narrated from Jaabir ibn ‘Abd-Allaah (may Allaah be pleased with him) that the Prophet (peace and blessings of Allaah be upon him) said:
“When the wings of the night spread – or when evening comes – keep your children in, for the devils come out at that time. Then when part of the night has passed, let them go. And close the doors and mention the name of Allaah, for the shaytaan does not open a closed door. And tie up your waterskins and mention the name of Allaah, and cover your vessels and mention the name of Allaah, even if you only put something over them, and extinguish your lamps.”
Narrated by al-Bukhaari (3280) and Muslim (2012). A version narrated by Muslim says:
“Cover vessels, tie up waterskins, close doors and extinguish lamps, for the shaytaan does not undo waterskins or open doors or uncover vessels.”
Imam al-Nawawi included this in a chapter entitled:
Chapter of the command to cover vessels, tie up waterskins, close doors and mention the name of Allaah over them, and extinguish lamps and fires when going to sleep, and keeping children and livestock in after sunset. End quote.
Imam Muslim narrated in the same chapter that Jaabir ibn ‘Abd-Allaah (may Allaah be pleased with him) said: The Messenger of Allaah (peace and blessings of Allaah be upon him) said: “Do not let your animals and children go out when the sun has set, until the first part of the night is over, for the devils come out when the sun sets, until the first part of the night is over.”
Ibn Hibbaan narrated it in his Saheeh (4/90) as follows: “Tie up your water skins and close your doors when you go to bed at night, and cover food and drink, for the shaytaan comes, and if he does not find the door closed he will enter, and if he does not find the waterskin tied up he will drink from it, and if he finds the door closed and the waterskin tied up, he does not open any water skin and he does not open a closed door, and if one of you cannot find something to cover his vessel in which is his drink, let him a place a stick over it.”
Imam Ibn Abd al-Barr (may Allah have mercy on him) said: “In this hadeeth there is a command to close doors of houses at night. This is a Sunnah which is enjoined to protect people against the devils of mankind and the jinn. As for the words “the shaytaan does not open a closed door and he does not untie a water skin” this is telling us of the blessing of Allaah, may He be glorified and exalted, to his human slaves, for he(the shaytaan) has not been given the power to open the door, or undo a water skin or uncover a vessel; these things have been forbidden to him, even though he has been given the power to do some things that are more difficult than that, such as going through and penetrating in ways that man cannot.” End quote.
Al-Haafiz Ibn Hajar (may Allah have mercy on him) said: “Ibn Daqeeq al-‘Eid said: in the command to close doors there are both religious and worldly benefits which protect lives and wealth from evildoers, and especially the devils.
As for the words “the shaytaan does not open a closed door,” this is an indication that the command to close doors serves the purpose of keeping the shaytaan away from mixing with people. The reason given is something that can be known through Revelation. The definite article is referring to the type, it does not mean any specific individual.” End quote.
Fath al-Baari, 11/87.