[fix] prevent closing already closed file