Fix handling of closed stdin/stdout/stderr on mingw.