It depends on the situation and your personal safety.
Legal Considerations: In most places, it is illegal to physically harm someone, even if they are yelling at you. You should always prioritize de-escalation and avoid violence.
Safety First: If you feel threatened or unsafe, you should remove yourself from the situation as quickly and safely as possible. Call for help if necessary.
Verbal Defense: You can try to de-escalate the situation by calmly and assertively stating that you don't want to be yelled at and that you're leaving.
Physical Defense: In extreme circumstances, if you feel your safety is in immediate danger, you may have the right to use reasonable force to defend yourself. This is a complex topic and the laws vary depending on your location.
Seeking Help: If you are experiencing repeated or escalating threats, consider seeking help from law enforcement or a trusted professional.
Remember: Your safety is paramount. Use good judgment and prioritize de-escalation whenever possible.