Tweaking closing of hdf objects

[skip ci]