She had no alternative as she was trapped in a small enclosure.
NEVER (if you can help it) trap yourself thus because the bad guy may just have a gun (YOU DON’T KNOW FOR SURE) and could just pump shots into that closet and there is no where to hide.
Last resort choice ONLY.
Pray tell me. Where are you supposed to run to upstairs with three children in tow?