The process of passing arguments to IO calls can cause allocations that
get referenced during EndIO calls. Calling "Finalize" causes these
allocations to be deallocated. This means that references to them in
the code in EndIO will be invalid. The fix is to delay the call to
"finalize" until after the call to EndIO.
This particularly causes problems with the IO items are strings that are
produced by calls to functions.