Fix potential race condition between shutdown of cache and channel.