The same applies to helping other people—while you should definitely help other people to safety when you can, once you're in a safe space, none of you should leave. You should be extremely wary of anyone trying to gain access to your safe space before the danger has passed. Shooters, for example, are often looking for rack up the body count as high as possible as quickly as possible—opening the door to your safe space may give them an opportunity they wouldn't have otherwise. Remember, this isn't the movies, and your assailant won't look the other way while you "save one more person." By all means, if you're calm and in the headspace to help others, do it, but do it from a place of safety, and don't let someone else's indecision slow you down and extend the danger to everyone.
When police do arrive, stay where it's safe and stay quiet. Remember that their goal is to ensure security and to make an unsafe situation safe again—not just for you, who may be stuck inside—but for other first responders, like firefighters and EMTs, to see to people who may be injured or need evacuation. If you hear or see police, don't come rushing out from your safe space until ordered to do so—just because they're there doesn't mean the area is safe yet.