Right, if a unit is below half health and they get attacked by a building, they retreat.
It's meant to be feature actually, a reason to keep your towers alive. Not only do they see invisible rounds, but they help keep waves at bay.
If there seems to be no more attackers, just find the Tower that is still firing and clear it.
If I misinterpreted you, please give me more info.