Wikipedia says, that in case all connected components are open, a subset is clopen iff it is a union of connected components.
While the first implication has been shown in this post, I'm trying to prove the opposite direction.
Let $(X,\tau)$ be a topological space with the assumptions from above. Further let $A \subseteq X$ be the union of a family $(U_i)_{i \in I}$ of connected components.
Of course, $A$ is open (arbitrary union of open sets). But why is $A$ closed? I'm thinking proof by contradiction, by showing that for $A \subsetneq \bar A$ one $U_{i_0}$ can't be maximal but I haven't had success so far.
Problem: Take $x \in \bar A \setminus A$ and its respective connected component $U_x$. The assumptions are not violated, if $U_x = \{x\}$. Following this path I get, that $\bar A$ is clopen.
Any hints?