[misc] properly handle SIGTERM