Germany has had some weird court decisions in that regard, in general the law does say flee and not shoot back if this is an option. But mostly courts are reasonable and do not punish the victim. Only if the victim decides to use violence after the threat is over
https://www.hrr-strafrecht.de/3/15/3-199-15.php
But there was even a case, where a hells angel shot a police officer in his home who were doing a raid - and got free (because they did not identify themself as police).
https://www.lto.de/recht/hintergruende/h/bgh-spricht-hells-a...
The law says your are allowed to stand your ground. You don't have to flee.
> But there was even a case,
I don't know the details of the case, but if somebody thought some criminals are raiding his house with guns and it's reasonable the he thought that, then he's fully within his rights to defend himself and, depending on the necessities, by shooting at them.
Still terrible what happened, of course.