Let $G$ be a Hausdorff topological group and its center be the subgroup $Z = \{ x \in G \; | \; xgx^{-1} = g, \; \forall g \in G \}$. I have already seen the simpler proof [1] that the center is the intersection over all $g \in G$ of the sets $C_g$ of all elements that commute with $g$, and that as the pre-images of the identity under a continuous map, the $C_g$ are all closed and hence so is $Z$.
Here's what I came up with before I looked up the answer. I'd like to know if there are any mistakes. Thanks!
Let $x_n$ be a sequence in $Z$ with $x_n \to x$ (the sequence $(x_n)$ converges to $x$). Pick any $g \in G$ and define $f:G \to G$ by $f(x) = xgx^{-1}$. For all $n$, we have $f(x_n) = x_ngx_n^{-1} = x_nx_n^{-1}g = g$ because $x_n \in Z$.
Since $f(x_n)=g$, then $f(x_n)\to g$. Made from multiplication and inversion, $f$ is continuous, so $f(x_n) \to f(x)$. Finally, because $G$ is Hausdorff, limits are unique, so $f(x) = g$.
Therefore, $f(x) = xgx^{-1} = g$, implying $xg = gx$, so $x \in Z$. Because any sequence in $Z$ is shown to converge in $Z$, it must be the case that $Z$ is closed.
As mentioned by William elliot, this proof is only applicable to first countable spaces in which
$$x\in\bar A \Leftrightarrow \text{ there exists a sequence $\{x_n\}_{n\in \Bbb N}$ such that } x_n\to x$$
However, we simply need to 'upgrade' the concept of sequences to the concept of nets. For general topological spaces, the followings are standard results in which you can try to prove it after learning the definition:
$$x\in\bar A \Leftrightarrow \text{ there exists a net $\{x_\alpha\}_{n\in \Bbb N}$ such that } x_\alpha\to x$$
We also have
$$ f \text{ is continuous } \Leftrightarrow x_\alpha\to x \text{ implies }f(x_\alpha)\to f(x)$$
Now, your proof goes through provided that we replace $\{x_n\}$ by $\{x_\alpha\}$.