All of the schemes we will encounter during the rest of the proof are going to be of finite type over the Noetherian scheme $S$ and hence Noetherian (see Morphisms, Lemma \ref{morphisms-lemma-finite-type-noetherian}). All morphisms between them will automatically be quasi-compact, locally of finite type and quasi-separated, see Morphisms, Lemma \ref{morphisms-lemma-permanence-finite-type} and Properties, Lemmas \ref{properties-lemma-locally-Noetherian-quasi-separated} and \ref{properties-lemma-morphism-Noetherian-schemes-quasi-compact}. \medskip\noindent The scheme $X$ has only finitely many irreducible components (Properties, Lemma \ref{properties-lemma-Noetherian-irreducible-components}). Say $X = X_1 \cup \ldots \cup X_r$ is the decomposition of $X$ into irreducible components. Let $\eta_i \in X_i$ be the generic point. For every point $x \in X$ there exists an affine open $U_x \subset X$ which contains $x$ and each of the generic points $\eta_i$. See Properties, Lemma \ref{properties-lemma-point-and-maximal-points-affine}. Since $X$ is quasi-compact, we can find a finite affine open covering $X = U_1 \cup \ldots \cup U_m$ such that each $U_i$ contains $\eta_1, \ldots, \eta_r$. In particular we conclude that the open $U = U_1 \cap \ldots \cap U_m \subset X$ is a dense open. This and the fact that the $U_i$ are affine opens covering $X$ is all that we will use below. \medskip\noindent Let $X^* \subset X$ be the scheme theoretic closure of $U \to X$, see Morphisms, Definition \ref{morphisms-definition-scheme-theoretic-image}. Let $U_i^* = X^* \cap U_i$. Note that $U_i^*$ is a closed subscheme of $U_i$. Hence $U_i^*$ is affine. Since $U$ is dense in $X$ the morphism $X^* \to X$ is a surjective closed immersion. It is an isomorphism over $U$. Hence we may replace $X$ by $X^*$ and $U_i$ by $U_i^*$ and assume that $U$ is scheme theoretically dense in $X$, see Morphisms, Definition \ref{morphisms-definition-scheme-theoretically-dense}. \medskip\noindent By Morphisms, Lemma \ref{morphisms-lemma-quasi-projective-finite-type-over-S} we can find an immersion $j_i : U_i \to \mathbf{P}_S^{n_i}$ for each $i$. By Morphisms, Lemma \ref{morphisms-lemma-quasi-compact-immersion} we can find closed subschemes $Z_i \subset \mathbf{P}_S^{n_i}$ such that $j_i : U_i \to Z_i$ is a scheme theoretically dense open immersion. Note that $Z_i \to S$ is proper, see Morphisms, Lemma \ref{morphisms-lemma-locally-projective-proper}. Consider the morphism $$ j = (j_1|_U, \ldots, j_m|_U) : U \longrightarrow \mathbf{P}_S^{n_1} \times_S \ldots \times_S \mathbf{P}_S^{n_m}. $$ By the lemma cited above we can find a closed subscheme $Z$ of $\mathbf{P}_S^{n_1} \times_S \ldots \times_S \mathbf{P}_S^{n_m}$ such that $j : U \to Z$ is an open immersion and such that $U$ is scheme theoretically dense in $Z$. The morphism $Z \to S$ is proper. Consider the $i$th projection $$ \text{pr}_i|_Z : Z \longrightarrow \mathbf{P}^{n_i}_S. $$ This morphism factors through $Z_i$ (see Morphisms, Lemma \ref{morphisms-lemma-factor-factor}). Denote $p_i : Z \to Z_i$ the induced morphism. This is a proper morphism, see Morphisms, Lemma \ref{morphisms-lemma-image-proper-scheme-closed} for example. At this point we have that $U \subset U_i \subset Z_i$ are scheme theoretically dense open immersions. Moreover, we can think of $Z$ as the scheme theoretic image of the ``diagonal'' morphism $U \to Z_1 \times_S \ldots \times_S Z_m$. \medskip\noindent Set $V_i = p_i^{-1}(U_i)$. Note that $p_i|_{V_i} : V_i \to U_i$ is proper. Set $X' = V_1 \cup \ldots \cup V_m$. By construction $X'$ has an immersion into the scheme $\mathbf{P}^{n_1}_S \times_S \ldots \times_S \mathbf{P}^{n_m}_S$. Thus by the Segre embedding (see Constructions, Lemma \ref{constructions-lemma-segre-embedding}) we see that $X'$ has an immersion into a projective space over $S$. \medskip\noindent We claim that the morphisms $p_i|_{V_i}: V_i \to U_i$ glue to a morphism $X' \to X$. Namely, it is clear that $p_i|_U$ is the identity map from $U$ to $U$. Since $U \subset X'$ is scheme theoretically dense by construction, it is also scheme theoretically dense in the open subscheme $V_i \cap V_j$. Thus we see that $p_i|_{V_i \cap V_j} = p_j|_{V_i \cap V_j}$ as morphisms into the separated $S$-scheme $X$, see Morphisms, Lemma \ref{morphisms-lemma-equality-of-morphisms}. We denote the resulting morphism $\pi : X' \to X$. \medskip\noindent We claim that $\pi^{-1}(U_i) = V_i$. Since $\pi|_{V_i} = p_i|_{V_i}$ it follows that $V_i \subset \pi^{-1}(U_i)$. Consider the diagram $$ \xymatrix{ V_i \ar[r] \ar[rd]_{p_i|_{V_i}} & \pi^{-1}(U_i) \ar[d] \\ & U_i } $$ Since $V_i \to U_i$ is proper we see that the image of the horizontal arrow is closed, see Morphisms, Lemma \ref{morphisms-lemma-image-proper-scheme-closed}. Since $V_i \subset \pi^{-1}(U_i)$ is scheme theoretically dense (as it contains $U$) we conclude that $V_i = \pi^{-1}(U_i)$ as claimed. \medskip\noindent This shows that $\pi^{-1}(U_i) \to U_i$ is identified with the proper morphism $p_i|_{V_i} : V_i \to U_i$. Hence we see that $X$ has a finite affine covering $X = \bigcup U_i$ such that the restriction of $\pi$ is proper on each member of the covering. Thus by Morphisms, Lemma \ref{morphisms-lemma-proper-local-on-the-base} we see that $\pi$ is proper. \medskip\noindent Finally we have to show that $\pi^{-1}(U) = U$. To see this we argue in the same way as above using the diagram $$ \xymatrix{ U \ar[r] \ar[rd] & \pi^{-1}(U) \ar[d] \\ & U } $$ and using that $\text{id}_U : U \to U$ is proper and that $U$ is scheme theoretically dense in $\pi^{-1}(U)$.