The use of defense in law has two important elements that need to be emphasized.
First, the use of force is only justified when a person believes with warrant (that is it is reasonable) that it is necessary to use force for the sake of defending oneself or another against the immediate threat of unlawful force.
Second, a person cannot use more force than necessary based on the circumstances. For instance, a person cannot claim self-defense by shooting someone who was about to steal an iphone. In short, the force must be in proportion to the threat.
In light of these two points, we can summarize the definition of self-defense by saying that it is justifiable to use force (which at times can be fatal) when there is the threat of bodily harm.