Fix race between completion and cancellation