Let $X$ be a scheme and $(U_i)_{i\in I}$ an open covering,
(1) Given a subset $Z\subset X$, why does $Z\cap U_i$ is closed for all $i$ implies that $Z$ is closed?
(2) Let $A$ be a ring. Given a morphism schemes $f:X\rightarrow \operatorname{spec} A$ such that $f_Y:X \times_{\operatorname{spec}A} Y\rightarrow Y$ is closed for all affine $A$ schemes $Y$, does this imply that $f$ is universally closed?
(1) Because then
$$X-Z=\bigcup_i \left(U_i-(U_i\cap Z)\right)$$
and since $U_i\cap Z$ is closed in $U_i$ we see that $U_i-(U_i\cap Z)$ is open in $U_i$ and thus open in $X$.
(2) Yes, by 1). To check that $f$ is universally closed let $Y$ be any $A$-scheme. We need to show that $f(X_Y)$ is closed in $Y$. But, let $Y=\bigcup_i U_i$ for affine open subschemes $U_i$ of $Y$. By 1) it suffices to see that $f(X_Y)\cap U_i$ is closed for all $i$. But, note that $f(X_Y)\cap U_i=f(X_{U_i})$. Indeed, this follows from the Cartesian diagram
$$\begin{matrix} X_{U_i} & \to & X_Y & \to & X\\ \downarrow & & \downarrow & & \downarrow\\ U_i & \to & Y & \to & \mathrm{Spec}(A)\end{matrix}$$
So then, it suffices to show that $f(X_{U_i})$ is closed. But, since $U_i$ is an affine $A$-scheme we know this by assumption.