I want to prove the following proposition:
Let $X$ be a topological space, $A \subseteq X$ and $B \subseteq X$ connected subspaces such that $A\cap \overline{B} \ne \varnothing$. Then, $A\cup B$ is connected.
I am aware that this was already discussed in Union of connected subsets$ X$,$Y$ is connected if $\overline{X}\cap Y \neq \varnothing$, but I want to check my proof, which uses the inexistence of separation of a connected space, unlike the answer to the linked question.
My proof:
Suppose $A\cup B$ is not connected. Thus, there exists a separation $(U,V)$ of $A\cup B$ (i.e there are non-empty disjoint open sets $U,V$ of $A\cup B$ such that $U\cup V=A\cup B$).
Since $A\subseteq A\cup B$ is an open set of the topological space $A$ and $V$ is open in $A\cup B$, then $A\cap V$ is an open set of the space $A$ (with the subspace topology). By the same token, $A\cap U$ is also an open set of $A$.
Clearly, $(A\cap U)\cup (A\cap V)=A$. Hence, if $A\cap U$ and $A\cap V$ are both nonempty, then we've arrived at a pair of disjoint nonempty open sets of $A$ whose union is $A$ $\rightarrow$ contradiction because $A$ is connected.
Hence, either $A\cap U=\varnothing$ or $A\cap V=\varnothing$ (but not both, since the points of $A$ must be in one of them). Let's suppose, without loss of generality, that $A\cap V=\varnothing$ (and so $A\cap U\ne\varnothing$).
Now, just like for $A$, we have $B\cap U=\varnothing$ or $B\cap V=\varnothing$ (but not both). If $B\cap V=\varnothing$, then $(A\cup B)\cap V=(A\cap V)\cup (A\cap V)=\varnothing$, and hence $V=\varnothing$ (since $V\subseteq A\cup B$)$\rightarrow$ absurd. Thus $B\cap U=\varnothing$ and $B\cap V\ne\varnothing$.
From this, $A=U$ (if $x\in A$, then $x\in U$ or $x\in V$, and thus $x\in U$; reciprocally, if $x\in U$ then $x\in A$ or $x\in B$, and so $x\in A$). Similarly, $B=V$.
Therefore, $a$ and $B$ are a separation of $A\cup B$ (in fact, by what we've just seen this is the only possible separation of $A\cup B$).
Now, let $x\in A\cap \overline{B}$. Since $x\in A$,$\ x\notin B$. but $B$ is closed and so $B=\overline{B}$. Hence, $x\in A$,$\ x\notin \overline{B}$ $\rightarrow$ absurd.
Therefore, $A\cup B$ is connected. $\ \square$
My question:
I've written (in bold) that "$B$ is closed and so $B=\overline{B}$". But I don't know how to justify that $B$ is closed (in $X$). It is closed in $A\cup B$, since $A$ is open and $(A\cup B)-B=A$, but how can I conclude that it is closed in $X$?