Do the SIGTERM cleanup outside the signal handler