[Examples]: Cleaned up memory leaks in all examples

Cleaned up the memory leaks in the 3-level hierarchical examples, so they
now properly clean up after themselves.