fn cancel_task<T: Future, S: Schedule>(core: &Core<T, S>)
Cancels the task and store the appropriate error in the stage field.