Fix The Handle is Invalid error on Windows 11/10