Fixed resource leaks in examples.