# Integral morphisms are closed

Let $$\pi: X \to Y$$ be an integral morphism of schemes, i.e., a morphism which is affine and such that for any affine open $\operatorname{Spec} B\subset Y$, we have $\pi^{-1} \operatorname{Spec} B =\operatorname{Spec} A \subset X$, such that the induced ring morphism $$\pi^\sharp:B\to A$$ is integral. I want to show that every integral morphism is closed. In the affine case it is easy: a closed subset of $\operatorname{Spec} A$ is defined by an ideal $I\subset A$. There is the corresponding ideal $J=(\pi^\sharp)^{-1}(I)\subset B$. Now notice that $$\pi^\sharp:B/J\to A/I$$ is an integral extension. Then take $\operatorname{Spec}$ of the above and use Lying Over Lemma.

Is it possible to reduce the general case to the affine case? If $K\subset X$ is closed, then I can take a cover of $X$ by affines and intersect with $K$ to get a cover of $K$, but this cover may be horribly infinite... Or I can consider $\pi(K)$ and cover it and try to use the fact that $\pi$ is affine. I don't think these steps will lead me anywhere.

Given a topological space $T$ together with an open covering $\{U_i\}_{i\in I}$, a subset $Z\subset T$ is closed in $T$ if and only if $T\cap U_i$ is closed in $U_i$ for all $i$. Now just note that $\pi(K)\cap U=\pi(K\cap \pi^{-1}(U))$, and apply this to $U$ affine.