smart shut down with SIGTERM or CONTROL C