Fix race condition in producer's Close()