Is It Sunnah to Close The Doors at Night?
Question

Is this Hadith authentic: “At the time of sunset, we say Bismillah and close the windows so that the jinn will not enter”?
Praise be to Allah.It is narrated in an authentic report that the Prophet (peace and blessings of Allah be upon him) commanded us to close the doors and mention the name of Allah at night, when night begins, when going to sleep. That is so that the Muslim may protect his house and his family from any harmful devil coming in, whether from among mankind or the jinn, and from harmful animals or insects coming in.
It was narrated from Jabir ibn `Abd-Allah (may Allah be pleased with him) that the Prophet (peace and blessings of Allah 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 Allah, for the devil does not open a closed door. And tie up your waterskins and mention the name of Allah, and cover your vessels and mention the name of Allah, even if you only put something over them, and extinguish your lamps.” (Narrated by Al-Bukhari, 3280 and Muslim, 2012). A version narrated by Muslim says: “Cover vessels, tie up waterskins, close doors and extinguish lamps, for the devil does not undo waterskins or open doors or uncover vessels.” 
Imam An-Nawawi (may Allah have mercy on him) included this in a chapter entitled: 
“Chapter of the command to cover vessels, tie up waterskins, close doors and mention the name of Allah over them, extinguish lamps and fires when going to sleep, and keep children and livestock in after sunset.” 
Muslim (2013) narrated in the same chapter that Jabir ibn `Abd-Allah (may Allah be pleased with him) said: The Messenger of Allah (peace and blessings of Allah 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 Hibban narrated it in his Sahih (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 devil 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 Hadith 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 devil does not open a closed door and he does not untie a water skin” this is telling us of the blessing of Allah, may He be glorified and exalted, to his human slaves, for he (the devil)  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.” (Al-Istidhkar, 8/363) 
Ibn Hajar (may Allah have mercy on him) said: 
“Ibn Daqiq 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 devil does not open a closed door,” this is an indication that the command to close doors serves the purpose of keeping the devil 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.” (Fath Al-Bari, 11/87) 
He also said (may Allah have mercy on him): 
“Al-Qurtubi said: All commands on this issue are aimed at serving an interest for man, and are to be understood as recommendations, especially with regard to the one who does that with the intention of following the command. 
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. It is as if the night is singled out in this case because the day is usually the time when people are awake, unlike the night. The whole idea is connected to the devil, because he is the one who makes the mouse burn the house.” (Fath Al-Bari, 6/356 -357) 
Al-Khatib Al-Shirbini Ash-Shafi`i (may Allah have mercy on him) said: 
“When night comes, it is Sunnah to cover vessels even if only with a stick, to tie up water skins, and to close doors, mentioning the name of Allah in all three cases, and to keep children and livestock in during the first part of the night, and to extinguish lamps when going to sleep.” (Mughni Al-Muhtaj, 1/31) 
Shaykh Ibn `Uthaymin (may Allah have mercy on him) said: 
“When going to sleep, one should close the door.” (Sharh Riyadh As-Salihin) 
For more details, please refer to the following answers: 10513 , 42073 , 97221 and 146797 . 
And Allah knows best.