catch SIGHUP and SIGTERM and raise an exception (#3656)