Fix handling of closing streams on HDF5 files