“When the wings of the night spread , keep your children in, for the devils come out at that time”
Question

We have grown up being told that at Maghrib time children should not go out to play as this is the time the Jinn (spirits) and devils come out and that they will possess any children playing outside. Is there any basis to this?
Praise be to Allah.Yes, a number of saheeh ahaadeeth (Prophetic narrations) were narrated concerning this etiquette. For example, it is narrated from Jaabir 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 shaytaan (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).  
Al-Nawawi included this in a chapter entitled Chapter on covering vessels, tying up waterskins, locking doors, mentioning the name of Allah over them, extinguishing fires and lamps when going to sleep, and keeping children and livestock in after Maghrib. 
Muslim (2013) also narrated from Jaabir (may Allah be pleased with him) that he 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.” 
Al-Haafiz ibn Hajar (may Allah have mercy on him) said concerning the first hadeeth: 
“The wings of the night” refers to when night comes after the sun has set. 
The words “then let them go” – Ibn al-Jawzi said: Rather there is fear for children at that hour, because the najaasah (impurity)that the shayaateen (devils) seek is usually present with them at that time, and the dhikr (remembrance of Allah) that would protect them is usually absent from children, and when the shayaateen spread out they hang on to whatever they can hang on to. Hence there is fear for children at that time. 
The reason why they spread out at that time is that they are more able to move about at night than during the day, because darkness is more conducive to devil forces coming together than any other time. End quote.  
Fath al-Bari, 6/341 
al-Nawawi (may Allah have mercy on him) said: 
This hadeeth includes a number of types of goodness and etiquette which combine the interests of both this world and the Hereafter. The Prophet (peace and blessings of Allah be upon him) enjoined these etiquettes which are the cause of safety from the harm of the shaytaan (devil) , and Allah has made all of these means causes of being safe from his harm. He is not able to uncover vessels or untie waterskins or open doors or harm children or others if these means are followed. This is like what it says in the saheeh hadeeth, (authentic narration) that if a person says Bismillah when entering his house, the shaytaan (devil) says “No place to stay” i.e., we have no authority to stay overnight with these people. And if a man says when having intercourse with his wife, “O Allah, keep the shaytaan away from us and keep the shaytaan away from what You bestow upon us (of offspring),” that will be a cause of the child being kept safe from the harm of the shaytaan. This is similar to this hadeeth, which is well known among saheeh ahaadeeth. 
This hadeeth encourages us to remember Allah in these cases and other similar situations. Our companions said: It is mustahabb (preferred) to mention the name of Allah over everything that matters, and to praise Allah at the beginning of everything that matters, because of the well known hasan hadeeth (sound narrations). 
The words “wings of the night” is a well known phrase that refers to the darkness of the night. And it was said that it refers to when the darkness of night comes.  
The words of the Prophet (peace and blessings of Allah be upon him) “Keep your children in” mean: prevent them from going out at that time. 
The words “for the devils come out at that time” mean that there is the fear at this time that children may be subjected to the devils’ harm because there are so many of them at that time. And Allah knows best. End quote. 
Sharh Muslim (13/185). 
The Standing Committee for Issuing Fatwas was asked the following question: 
In the saheeh hadeeth narrated by al-Bukhari, it says: “When the wings of the night spread, or when evening comes, keep your children in.” Then it says: “And extinguish your lamps.” Does this command mean that it is obligatory? If it is mustahabb, what is the evidence to show that it is not obligatory?  
They replied: The commands mentioned in this hadeeth are to be understood as recommendations and advice, according to most scholars, as was stated by a number of scholars, such as Ibn Muflih in al-Furoo’ (1/132), al-Haafiz Ibn Hajar in Fath al-Bari (11/97). And Allah knows best. End quote. 
Fatawa al-Lajnah al-Daa’imah (26/317) 
And Allah knows best.