Clean up memory in examples.