A morphism $f : X \to Y$ is a closed immersion if and only if there exists an affine open cover $ \{ U_i \}$ such that $f|_{f^{-1}(U_i)} : f^{-1}(U_i) \to U_i $ is a closed immersion for all $i$.
It's so fundamental, but I can't show it. The stalk property - for all $ x \in X$ $f^{\#}_x : \mathscr{O}_{Y,f(x)} \to \mathscr{O}_{X,x} $ is surjective - is trivial, but I don't understand why $f(X)$ is closed in $Y$.