fixed bugs in closing HDF5 file