Used with when open hdf5 file, to handle close correcly in cases when opening\creating\appending\closing fails