Free allocated memory on process termination