Criterion for closed point in scheme of finite type. Let $X$ be a scheme of finite type over an algebraically closed field $k$. Then there is a statement that:
A point $x$ is closed if and only if the composition $k\to \mathcal{O}_{x,X}\to \mathbb{k}(x)$ is surjective.
The proof of the case that $X$ is affine is given, and it's said that the general case follows easily. But I don't know how to pass to the general case. Even though we can take affine covers of $X$, but $x$ closed in an open set doesn't necessarr means being a closed point. It's also said this criterion is false for general schemes. Hope someone could help. Thanks!
 A: Being open in a single affine chart doesn't guarantee what you want, but being open in every affine in a cover of X does; that is, we have the following statement:

If $X$ is a scheme and $X=\bigcup_iU_i$ is an affine open cover, then $x\in X$ is closed in $X$ if and only if $x$ is closed in $U_i$ for each $i$ with $x\in U_i$ (we can rephrase the latter statement as the condition that $\{x\}\cap U_i$ is a closed subset of $U_i$ for each $i$).

If $x$ is closed in $X$ then it's clear $\{x\}\cap U_i$ is closed in $U_i$ for each $i$; on the other hand, if $\{x\}\cap U_i$ is closed in $U_i$, then this is the same as the condition that $U_i\smallsetminus\{x\}$ is open in $U_i$ (hence open in $X$), and we can calculate $$X\smallsetminus\{x\}=\big(\bigcup_i U_i\big)\smallsetminus\{x\}=\bigcup_i (U_i\smallsetminus\{x\})$$
and this is open in X, being a union of open subsets of $X$, so $x$ is a closed point in $X$.
So then to our situation, instead of looking at a single affine open containing $x$ you need to consider the affine situation for every affine open containing $x$ in some cover, and conclude $x$ is closed in each of these affines.
