sim_BuildROMs: Fix potential memory leaks and a double fclose.