Fixed file handle/descriptor closing