fixed the function to delete alarm when instance terminated.