From the walkthrough:
Continuously shoot at the monkeys and the more
consecutive direct hits lowers the bar on top of the screen. Once the green line
of the bar disappears, the monkeys get tired of shooting at you and leave.
It's also possible to sneak around a different route behind the monkeys, thereby avoiding having to fight altogether.