Separated morphisms are stable under base change Suppose that the map $f$ in the following diagram is a separated morphism (i.e. $\Delta_{X/S}:X\rightarrow X\times_{S}X$ is a closed immersion). I want to prove that $p_{2}$ is also a separated morphism. 
$$\require{AMScd}$$
\begin{CD}
X\times_{S}Y @>{p_{1}}>> X\\
@VV{p_{2}}V @VV{f}V\\
Y @>{h}>> S
\end{CD}
To prove that $p_{2}$ is also separated we have to show that the diagonal morphism $\Delta_{X\times_{S}Y/Y}: X\times_{S}Y\rightarrow (X\times_{S}Y)\times_{Y}(X\times_{S}Y)$ is a closed immersion. 
My strategy was to construct a cartesian diagram containing the $\Delta_{X/S}$ and $\Delta_{X\times_{S}Y/X}$ and use the fact that closed immersions are stable under base change, i.e. if we have a cartesian diagram 
$$\require{AMScd}$$
\begin{CD}
Z @>>> Y\\
@VVV @VVV\\
X @>>> S
\end{CD}
such that $X\rightarrow S$ is a closed immersion, then also $Z\rightarrow Y$ is a closed immersion. 
Unfortunately I couldn't find such a cartesian diagram.

I guess that your right horizontal $g$ in your first diagram is your $f: X \to S$ and your $p_2: X \times_S Y \to Y$ is the pullback of $f$ along horizontal $Y \to S$ (you called it also $f$ but in your first sentence you reserved $f$ for $X \to S$. Let call the horizontal arrow $Y \to S$ $h$. Clearly the diagram below is a pullback because $X \times_{ X \times_S X}  (X\times_{S}Y \times_Y X\times_{S}Y) = X \times_{ X \times_S X} X \times_S X \times_S Y=X\times_{S}Y$ (use universal property of fiber product).
\begin{CD}
X\times_{S}Y @>{p_{1}}>> X\\
@VV\Delta_{}V @VV\Delta_{X/S}V\\
X\times_{S}Y \times_Y X\times_{S}Y @>{pr \times_h pr}>> X \times_S X
\end{CD}
Now closed immersions are preserved under base change and you assumed $\Delta_{X/S}:X\rightarrow X\times_{S}X$ be closed immersion.
