Let $G$ be a topological group. Define $H(g)=\{g^n\}^{\infty}_{n=-\infty}$ for each $g \in G$. I need to prove that the closure of the set $H(g)$ is a commutative subgroup of $G$. But I am not sure how to interpret the closure of $H(g)$.
I already appreciate your explanations
You have to assume that $G$ is Hausdorff, otherwise this does not work (see here).
Let $K$ be the closure of $H(g)$. Given $g,h\in K$, take nets $(g_\lambda)_{\lambda\in\Lambda}$ and $(h_\mu)_{\gamma\in\Gamma}$ in $H(g)$ such that $g_\lambda\to g$ and $h_\gamma\to h$. Since multiplication is continuous, the net $(g_\lambda h_\gamma)_{(\lambda,\gamma)\in\Lambda\times\Gamma}=(h_\gamma g_\lambda)_{(\lambda,\gamma)\in\Lambda\times\Gamma}$ (which is in $H(g)$, since it is a subgroup) converges to both $gh$ and $hg$, so $gh=hg\in K$ (by the Hausdorff property). This shows that $K$ is a commutative subgroup of $G$.