Throw exception on resource leak in debug build

Fix resource leak in example project