Free memory when exiting the process.