Clean up allocated global memory on exit