io: fix file:close() and file:__gc() blocking