More robust task deletion