Fix race condition in cancel channel