I have the same issue with freezing (or apologising on repeat even when it's not my fault), especially in situations where I'm tired, low on spoons or (annoyingly!) in the workplace. However as far as I'm concerned, once someone is communicating with you by yelling, that's their problem, not yours. They're the ones who have caused the communications channels to break down & they're being abusive.
My advice is to explain that you're walking away from the situation & do exactly that (similar to a customer service rep hanging up on an abusive caller). You may need to develop & practice your explainer until you've got it flowing smoothly so you can just deliver it even with your mind frozen. If you can't deliver it in that state, don't worry, just walk away.
Keep your explainer short, a sentence or two at most (e.g. I'm walking away now as you're yelling at me. Please calm yourself down if you want to talk to me again.). Do not attempt to engage them further & keep away from them until they've got control over themselves.
Then make sure you get somewhere safe with other people around as social protection if the person yelling tries to follow you or escalate.