Fix race condition where channel closed before read