fix potential deadlock when closed w/o pending writes