(To) beat a retreat is a phrase. The meaning of the phrase is to withdraw or to retire as a sign of defeat.
1. When our soldiers attacked the enemy post with great courage, the enemy had to beat a retreat in haste.
2. Her arguments in the case was so strong that the other party had to beat a retreat.
3. The Indian soldiers faced the enemy with such a courage and boldness that the enemies were compelled to beat a retreat.