Added guards to prevent crashing after processing is cancelled.