Is this a correct proof that the center of a Hausdorff group is closed? 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.
[1] Center of compact lie group closed?
 A: 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\}$.
A: Let $G$ be a topological group. For $h\in G$, define $c_h:G\to G$ by $g\mapsto ghg^{-1}h^{-1}$; it is continuous
Then the center of $G$ is $Z(G)=\bigcap_{h\in G}c_h^{-1}(\{1\})$. In particular if $G$ is Hausdorff, $\{1\}$ is closed and hence $c_h^{-1}(\{1\})$ is closed, and hence so is the center.
One can essentially restate this using the continuous map $c:G\to G^G$ ($G^G$ being endowed with Tychonov product topology) whose $h$-component is $c_h$. Then $Z(G)=c^{-1}(\{1\})$, where here $1$ is the constant function $1\in G^G$. Again, if $G$ is Hausdorff, $\{1\}$ is closed in $G^G$ and hence $c^{-1}(\{1\})$ is closed.
Using inversion is this is a bit cheating because there's an argument working for topological semigroups, and more generally topological magmas (topological magma = topological space $G$ endowed with continuous binary law, where the center is defined as $Z(G)=\{g:\forall h:gh=hg\}$). Let $G$ be a topological magma, and for $h\in G$ define $q_h:G\to G^2$ by $q_h(g)=(gh,hg)$; it is continuous. Let $\Delta$ be the diagonal in $G^2$. Then $Z(G)=\bigcap_{h\in G}q_h^{-1}(\Delta)$. In particular if $G$ is Hausdorff then $Z(G)$ is closed. (Also this can also be restated using an equalizer of two product maps.)
