Ensure that HDF5 file is always closed
Fix tutorial example