Fixed up process flow so app can self-terminate;