Parting Shot
Most commonly now the term Parting Shot is used when someone issues one last verbal assault as they leave the area. The origin of the phrase is fairly similar.
The Parthian dynasty of Persia (which would become modern-day Iran) used a number of light horse archers in their army. One of their favorite tactics was to pretend to be routed and flee the battlefield. When their pursuers closed in for the kill the archers would turn in their saddle and deliver a surprise volley of arrows. This was usually very effective in turning the tide of a battle.
The tactic itself became known as the “Parthian Shot”, through the vagaries of translations and langue it eventually morphed into “parting shot”. When it went from launching arrows to tossing out a few last words is a little more difficult to tell, but the idea is the same.