If you are involved in a collision and can still exit your vehicle safely always use extreme caution to avoid secondary injury. Following the shock of a crash you may not be thinking clearly or may be confused or disoriented. It is critical that you carefully evaluate the situation for other risks or hazards. This might be other cars still in motion, icy roads that you are not steady enough to stand on, leaking fuel, or any number of other hazards.
Consider, for example, the common situation of being "rear-ended" by another vehicle. In a minor situation the tendency for most is to get out, walk to the rear, and check how bad the damage is. This means standing between your car and the vehicle which just hit you. What if that driver is in shock, injured perhaps from an airbag, or even impaired? The vehicle is likely still in gear and if their foot comes off the brake it could easily move forward pinning you between the vehicles?
As every crash situation is different there is no way of determining which is always the best course of action but giving this some thought beforehand may help deal with the aftershock.