Free memory at the end

an instruction has been added to clear the memory after the file is
generated