beat off
US /biːt ɔːf/
UK /biːt ɔːf/

1.
to masturbate (vulgar slang)
:
•
He was caught beating off in the bathroom.
•
Some people use pornography to beat off.
2.
to repel an attack or an attacker
:
•
The defenders managed to beat off the enemy assault.
•
She used a stick to beat off the aggressive dog.