added TERM signal handler and cosmetic changes for ctrl-app