remove System.exit() and attempt to fix non-termination