Fix resource leakage in example