sanitycheck: close pipe file handles

Make sure we close the pipe file handles after we are done, otherwise we
will end up with too many open file descriptors and crash...

Fixes #20974
Fixes #21637

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
diff --git a/scripts/sanitycheck b/scripts/sanitycheck
index 849d143..59061e6 100755
--- a/scripts/sanitycheck
+++ b/scripts/sanitycheck
@@ -812,12 +812,15 @@
 
         t.join(self.timeout)
         if t.is_alive():
-            logger.debug("Timed out")
+            logger.debug("Timed out while monitoring serial output on {}".format(self.instance.platform.name))
             out_state = "timeout"
 
         if ser.isOpen():
             ser.close()
 
+        os.close(write_pipe)
+        os.close(read_pipe)
+
         handler_time = time.time() - start_time
 
         if out_state == "timeout":