Make sure task exists and is running before terminating