fix handle leak in vp_pipe_open()

Also fix the wrong usage of CRT functions.  A handle returned by
_get_osfhandle() should not be passed to CloseHandle(), because it will
be closed automatically when closing the fd using _close().