All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger. We ask Allaah to exalt his mention as well as that of his family and all his companions.
The Prophet said: "When the first part of the night comes (i.e. sunset), prevent your children (from going out) as the devils spread at that time and when the first hour of the night is over, then allow them to go out." [Al-Bukhari and Muslim] The command in this narration is not to obligate but rather guiding to what is in the best interest, and it might be that it is desirable to do so, especially if one does so with the intention of acting according to the Sunnah; this meaning has been said by Al-Qurtubi. 'When the first hour of the night is over there is no harm for children to go out.' Ibn Al-Jawzi explained the wisdom of specifying the "children" in the narration, saying: "It is because the impurity to which devils tend to cling to is often present with them (i.e. children who may urinate and not clean themselves and remain impure), and children do not protect themselves by saying the designated remembrances which protects them from the devil, and when the devils spread, they attach themselves to whatever they could cling to." It appears that children who go out to pray the Maghrib prayer are not included in this, rather their going to the mosque is a recommended and legislated matter, and it could be, Inshaa' Allaah, a reason for their protection. However, we advise that they be accompanied at that time with an elder person and protect themselves by saying the designated remembrance of Allaah when going and coming back from the mosque.
Allaah knows best.