--- a/sched_setscheduler.c
+++ b/sched_setscheduler.c
@@ -64,6 +64,8 @@
 		 (0xFF & ERROR_ACCESS_DENIED)) ? EPERM : ESRCH;
 	      return -1;
 	    }
+	  else
+	    CloseHandle(h);
 	}
     }