Add cancellation to tasks