That’s not how that law works. First, you need to be legally in possession of the weapon, which would not be the case here. Second, the law only means you are entitled to use deadly force in defense of an assault, even if retreating is an option. It doesn’t mean you can just shoot on sight anyone brandishing a weapon.
The correct answer is that, like Bernhard Goetz, that teacher could be tried and convicted of possession of an illegal firearm. They might get a light sentence, but they would probably still be charged.
If the teacher accidently killed a student with an illegal firearm, there could be a whole host of other charges
They should be charged and prosecuted, in my opinion. It should fall to the judge to then discharge (hope that’s the right word) , as in excused. I’m not seeing the problem really. Everyone would fulfill their obligations.
The real question for me is would the parents of the shooter be able to sue for wrongful death and get a payout?