Let me specify that my knowledge about Lie groups/algebras is reduced to bits and pieces I learned from various diff geometry textbooks. I could not find a reference for the following question (I am not sure if it is true to start with):
Suppose $G$ is connected compact Lie group. I know that $l=Lie(G)$ splits into a direct product of Lie algebras $[l,l]$ and $z(l)$. If $H \leq G$ is connected such that $Lie(H)=[l,l]$, since $[l,l]$ is semi-simple with negative definite Killing form, an argument using Myers theorem gives that $H$ is a closed(embedded) subgroup of $G$.
Now let $Z \leq G$ such that $Lie(Z)=z(l)$. Clearly $Z$ is Abelian. Can one deduce that $Z$ is also a closed (or embedded) subgroup? Is there a choice of Z that satisfies this? Is it true for all such $Z$?
(Assuming the $Z$ you've defined is the same as the usual "center" of a group.)
Let $C_g=\{g_1\in G\mid g_1g=gg_1\}$. This set is closed, it is the inverse image of the closed set $\{e\}$ of the continuous function $G\to G$ defined as $g_1\mapsto gg_1g^{-1}g_1^{-1}$.
But $Z=\bigcap_{g\in G} C_g$ then also must be closed.