To prove $f$ is universally closed we will verify the existence part of the valuative criterion for $f$ which suffices by Schemes, Proposition \ref{schemes-proposition-characterize-universally-closed}. To do this, consider a commutative diagram $$ \xymatrix{ \Spec(K) \ar[r] \ar[d] & X \ar[d] \\ \Spec(A) \ar[r] & S } $$ where $A$ is a valuation ring and $K$ is the fraction field of $A$. Note that since valuation rings and fields are reduced, we may replace $U$, $X$, and $S$ by their respective reductions by Schemes, Lemma \ref{schemes-lemma-map-into-reduction}. In this case the assumption that $h(U)$ is dense means that the scheme theoretic image of $h : U \to X$ is $X$, see Lemma \ref{lemma-scheme-theoretic-image-reduced}. We may also replace $S$ by an affine open through which the morphism $\Spec(A) \to S$ factors. Thus we may assume that $S = \Spec(R)$. \medskip\noindent Let $\Spec(B) \subset X$ be an affine open through which the morphism $\Spec(K) \to X$ factors. Choose a polynomial algebra $P$ over $B$ and a $B$-algebra surjection $P \to K$. Then $\Spec(P) \to X$ is flat. Hence the scheme theoretic image of the morphism $U \times_X \Spec(P) \to \Spec(P)$ is $\Spec(P)$ by Lemma \ref{lemma-flat-base-change-scheme-theoretic-image}. By Lemma \ref{lemma-reach-points-scheme-theoretic-image} we can find a commutative diagram $$ \xymatrix{ \Spec(K') \ar[r] \ar[d] & U \times_X \Spec(P) \ar[d] \\ \Spec(A') \ar[r] & \Spec(P) } $$ where $A'$ is a valuation ring and $K'$ is the fraction field of $A'$ such that the closed point of $\Spec(A')$ maps to $\Spec(K) \subset \Spec(P)$. In other words, there is a $B$-algebra map $\varphi : K \to A'/\mathfrak m_{A'}$. Choose a valuation ring $A'' \subset A'/\mathfrak m_{A'}$ dominating $\varphi(A)$ with field of fractions $K'' = A'/\mathfrak m_{A'}$ (Algebra, Lemma \ref{algebra-lemma-dominate}). We set $$ C = \{\lambda \in A' \mid \lambda \bmod \mathfrak m_{A'} \in A''\}. $$ which is a valuation ring by Algebra, Lemma \ref{algebra-lemma-stack-valuation-rings}. As $C$ is an $R$-algebra with fraction field $K'$, we obtain a commutative diagram $$ \xymatrix{ \Spec(K') \ar[r] \ar[d] & U \ar[r] & X \ar[d] \\ \Spec(C) \ar[rr] \ar@{-->}[rru] & & S } $$ as in the statement of the lemma. Thus a dotted arrow fitting into the diagram as indicated. By the uniqueness assumption of the lemma the composition $\Spec(A') \to \Spec(C) \to X$ agrees with the given morphism $\Spec(A') \to \Spec(P) \to \Spec(B) \subset X$. Hence the restriction of the morphism to the spectrum of $C/\mathfrak m_{A'} = A''$ induces the given morphism $\Spec(K'') = \Spec(A'/\mathfrak m_{A'}) \to \Spec(K) \to X$. Let $x \in X$ be the image of the closed point of $\Spec(A'') \to X$. The image of the induced ring map $\mathcal{O}_{X, x} \to A''$ is a local subring which is contained in $K \subset K''$. Since $A$ is maximal for the relation of domination in $K$ and since $A \subset A''$, we have $A = K \cap A''$. We conclude that $\mathcal{O}_{X, x} \to A''$ factors through $A \subset A''$. In this way we obtain our desired arrow $\Spec(A) \to X$. \medskip\noindent Finally, assume $f$ is quasi-separated. Then $\Delta : X \to X \times_S X$ is quasi-compact. Given a solid diagram $$ \xymatrix{ \Spec(K) \ar[r] \ar[d] & U \ar[r]^h & X \ar[d]^\Delta \\ \Spec(A) \ar[rr] \ar@{-->}[rru] & & X \times_S X } $$ where $A$ is a valuation ring with field of fractions $K$, there exists a unique dotted arrow making the diagram commute. Namely, the lower horizontal arrow is the same thing as a pair of morphisms $\Spec(A) \to X$ which can serve as the dotted arrow in the diagram of the lemma. Thus the required uniqueness shows that the lower horizontal arrow factors through $\Delta$. Hence we can apply the result we just proved to $\Delta : X \to X \times_S X$ and $h : U \to X$ and conclude that $\Delta$ is universally closed. Clearly this means that $f$ is separated.