Let $X$ be a scheme. If $x\in X$ is a closed point, then it corresponds to a maximal ideal in $\mathcal{O}_X(U)$ for some affine open subset $U\subseteq X$.
If I take an arbitrary open affine $\mbox{Spec}~A$ in $X$ and a maximal ideal $x$ in $A$, then $\{x\}$ is closed in $\mbox{Spec}~A$, but may not be closed in $X$. It might even be the case that $\overline{\{x\}}$ contains a point belonging to an affine that has empty intersection with $\mbox{Spec}~A$.
Or not? Maybe I'm missing some easy topological property here.
Is there an example for such a situation? Or is it actually the case that $\{x\}$ will also be closed in $X$? If not, under what hypotheses on $X$ are all maximal ideals in the rings of affine opens also closed points in $X$?
Thank you in advance.