If a unit is destroyed for any reason, all friendly units within 6" must immediately test for panic.
This covers situations such as when a unit is wiped out by missile fire, magic, close combat, pursuit or indeed any other occurrence. Obviously, it's best to leave the annihilated unit in place until the tests are taken in order to give a point to measure from.