Automatically manage the cancellation of jobs with RAII.