Why does surjectivity of the induced map show that a morphism of affine varieties has closed image? Let $\phi : X \rightarrow Y$ be a morphism of affine varieties and let $\phi^\ast : k[Y] \rightarrow k[X]$ be the induced map on coordinate rings.  My text says that if $\phi^\ast$ is surjective then $\phi(X)$ is closed in $Y$; the "proof" given is that $\phi(X) = V(\ker \phi^\ast)$.  Clearly $\phi(X) \subseteq V(\ker \phi^\ast)$ in general, but how do I get the other direction?
Here's what I have so far:
Consider the maps $\varepsilon_i \in k[X]$ with $\varepsilon_i(x_1, x_2, \ldots x_n) = x_i$.  Since $\phi^\ast$ is surjective, there are maps $\gamma_i \in k[Y]$ such that $\varepsilon_i = \gamma_i \circ \phi$.  If we let $\gamma = (\gamma_1, \gamma_2, \ldots \gamma_n)$ then $\gamma \circ \phi$ is the identity on $X$, but it's not even clear that the image of $\gamma$ lies in $X$, so I don't know what to do with this.
 A: The general result in commutative algebra is:
Theorem Let $\phi:A\to B$ be a homomorphism of commutative rings and let $f:\text{Spec}(B)\to \text{Spec}(A)$ be the corresponding continuous map between spectra. If $\phi$ is surjective, then $f(\text{Spec}(B))$ is a closed subset of $\text{Spec}(A)$.
Proof. We assert that $f(\text{Spec}(B))=V(\text{Ker}(\phi))$. If $p\in\text{Spec}(B)$, then $f(p)=\phi^{-1}(p)\supseteq \text{Ker}(\phi)$. Conversely, if $q\in V(\text{Ker}(\phi))$, then we wish to prove that $q=\phi^{-1}(p)=f(p)$ for some $p\in \text{Spec}(B)$. In fact, the following exercise completes the proof:
Exercise: Prove that $p=\phi(q)$ is a prime ideal of $B$ and that $f(p)=\phi^{-1}(p)=q$. (Hint: you will need to use the surjectivity of $\phi$ to prove that $p$ is an ideal of B. However, you will need to use the surjectivity of $\phi$ and the fact that $q\supseteq \text{Ker}(\phi)$ to show that $p$ is a prime ideal of $B$.)
Therefore, $f(\text{Spec}(B))=V(\text{Ker}(\phi))$ is a closed subset of $\text{Spec}(A)$. Q.E.D.
I hope this helps!
