Need to do try { ... } finally { Entities.destroyAll(app2); }, otherwise the AbstractManagementContext.gc thread gets left around and the ManagementContext instance will never be garbage collected.