diff --git a/scripts/runqemu b/scripts/runqemu
index f3527a4412..f9a1a0da32 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -1573,7 +1573,8 @@ def main():
 
         def sigterm_handler(signum, frame):
             logger.info("SIGTERM received")
-            os.kill(config.qemupid, signal.SIGTERM)
+            if config.qemupid:
+                os.kill(config.qemupid, signal.SIGTERM)
             config.cleanup()
             # Deliberately ignore the return code of 'tput smam'.
             subprocess.call(["tput", "smam"])
