avoid unsound `close` during `readdir`