Self-Defense Law In A Nutshell
Self-defense (or defense of others) with deadly force is generally authorized when a reasonable person would believe that the use of death force is necessary to prevent death or serious bodily harm to a person (i.e. there aren't non-deadly options that can accomplish this end) and a reasonable person would believe that the use of force will prevent death or serious bodily harm to a person, subject to exceptions that would not apply to a private individual using deadly force in a stampede situation.
Incidentally, every state and every country absolves someone of liability for homicide when deadly force is used in self-defense, or in the defense of others (not necessarily family), although the exact details of when this is justified varies slightly. For example, in D.C. v. Heller, the right to self-defense is considered a natural or universal right.
The analysis would be somewhat different if the shooter were in law enforcement, and would be different again in the case of a shooter who was in the military with more or less clear orders.
But, that legal standard doesn't get you to an answer.
The Complex Phenomena Called Stampedes
The analysis would be extremely fact rich, in the sense of exactly who one would attempt to shoot, what that would be likely to accomplish, and what other alternatives would be available. And, to do that, you also need to understand the phenomena of deadly stampedes which are complex and often somewhat counter-intuitive phenomena.
While there are circumstances where it could be legal self-defense or defense of others to shoot a stampeding individual to save someone's life, there are also many stampede circumstances where a use of force would not be justified.
In practice, most stampedes, as a matter of physics, can only be stopped by removing a crush of bodies from the rear, where they do not know that they are causing a deadly stampede, while those at the front who end up directly harming others are frequently physically incapable of stopping.
Essentially, in a typical stampede that causes death, the problem is an inability of the people at the front to communicate to the people at the back to slow down. And, when a stampede is caused by a genuine threat to the people at the back like a fire or a terrorist, there is nothing that would persuade the people at the back to slow down anyway.
So, usually, shooting to kill someone at the front of a stampede would not achieve the intended result of protecting someone in its path. The person shot would either continue to surge forward while dead under the crush of bodies behind them, or would have their dead body trampled over by the next person in line who also has no physical ability to do anything other than to surge forward. So, usually, using deadly force to shoot someone at the front of a stampede will be futile and only cause an unnecessary death.
Given that using deadly force in a stampede, if directly at people in the front, is almost always futile, the question for the judge or jury deciding the case becomes whether a reasonable person would know that at the time, which would have to be decided a case by case basis.
Sometimes it is obvious from someone in a vantage point to shoot at the front of a stampede that this would be futile and sometimes it isn't. This question would be highly fact specific and depend a lot upon exactly what information about the situation was available to the person shooting a person in the stampede.
The situation where deadly force might not be futile would be one in which there is no actual life threatening harm that people are fleeing in which the deadly force is directed at the people in the back who are driving the stampede (even though they don't know it), to shock them into ceasing to do so. But, in that situation, if the shooting is done by someone who understands the situation well enough to know that this is what is actually necessary, that person also may be capable of firing warning shots or shooting to injure with the same effect, so justification might also be in doubt.
Protecting Targets of Mobs v. Protecting Targets of Stampedes
A similar situation where the use of deadly force might be justified is something visually similar to a stampede, but quite different in what would work factually.
This is a mob that is about to attack someone, possibly armed with pitchforks or knives or clubs or broken bottles or a noose. In the case of a mob, the use of deadly force to protect someone threatened by the mob would almost always be a justified use of force in self-defense or the defense of others, because shooting someone in the front is likely to be both necessary and effective.