You can also set training limit, which will prevent training a unit, instead of killing it. This is not exactly what you're asking for, but it might be useful depending on your application.
Player - Limit training of Footman to 3 for Player 1 (Red)
Im not going to train them.... just i want is to make a limit on footman... ex. I cast thunder clap then after the effect 1 footman will create at front of me when i cast the skill 3 times the older footman will die....