adds code to main; mocks end manager in tests so tests can terminate while the manager behaves normally