Let $X$ be a topological space. Suppose $H$ and $K$ are closed subsets of $X$ such that $H \cup K$ and $H \cap K$ is connected. Prove that $H$ and $K$ are connected.
My work: Assume for the sake of a contradiction that exactly one $H$ or $K$ are not connected. Then WLOG let $H$ be not connected and so $H = A \cup B$ for nonempty disjoint subsets of $X$. But then,
$$H \cup K = \left(A \cup B \right) \cup K $$ $$H \cap K = \left(A \cup B \right) \cap K = \left(H \cap A\right) \cup \left(H \cap B\right)$$ We also have that $Cl(K)=K$ and $Cl(H)=H$ since $H$ and $K$ are closed. Also that $Cl(A) \cap B = A \cap Cl(B) = \emptyset$. I'm unsure how to reach a contradiction from this. Any help is appreciated, thanks!