Fix memory corruption when using Hdf5Archive #4870
Fixes issue #4769
What changes were proposed in this pull request?
Makes sure all HDF5 objects are deallocated in the proper order to keep it happy.
How was this patch tested?
Slightly updated unit tests pass without crashing. I actually let importWganDiscriminator() run for 10000 iterations without problems, but reduced it to 100 for this PR so it does not take too much time to run.