beat off (v.)

"drive (something) away by violent blows," 1640s, from beat (v.) + off (adv.). Meaning "masturbate" is recorded by 1960s.