With actions, it's easier to assign them names, rather than numbers.
So, you could add this:
destroy = aP addaction ["destroy","distance.sqs"]
Also, the script needs changing:
?(aP distance T1 > 2):exit
T1 setdammage 1
aP removeaction destroy
You didn't assign the action a name. Also, you changed the case of aP, which I think changes it. Also, the syntax for the if statement needed changing. Finally, the setdammage ranges from 0 to 1. 0 being completely healthy, 1 being dead. You fixed it.
Should work, haven't tested but if you have any problems just give us a bell. They're easy mistakes to make, and takes some time just to realise what's wrong.
-=GC=-Fungus1999