A loud, confident voice can draw attention and discourage unwanted behavior. If you have a safe chance to leave, take it immediately. Your priority is always to get to safety, not to confront someone.