fix handler leakage on Windows