Proof (Seifert-van Kampen for closed cover)
Choose neighbourhoods $A\cap B \subseteq U \subseteq A$ and $A\cap B\subseteq V\subseteq B$ that are open in $A$ and $B$ respectively and strongly deformation retract to $A\cap B$. $A\cup V = X\setminus (B \cup (A\setminus U))$ is open, since $A \setminus U$ is closed in a closed set $A$, and similarly $B\cup U$ is open.
Let $r: U \to A\cap B$ be a deformation retraction. By the gluing lemma, the extension $r': B\cup U\to B$ defined by $r|_B = \id_B$ and $r|_U = r$ is a deformation retraction since $B$ and $U = B\setminus A$ are closed in $B\cup U$. Similarly we have deformation retractions $A\cup V \to A$ and $U\cup V\to A\cap B$. Therefore the inclusion maps give isomorphisms $$ \begin{align*} π_1(A, x_0) &\to π_1(A\cup V, x_0), \\ π_1(B, x_0) &\to π_1(B\cup U, x_0), \\ π_1(U\cup V, x_0) &\to π_1(A\cap B, x_0). \end{align*} $$
Since $(A\cup V)\cap (B \cup U) = U\cup V$ is homotopic equivalent to $A\cap B$, it is path-connected, so Seifert-van Kampen yields an isomorphism $$ \begin{align*} π_1(A\cup V, x_0) *_{π_1(U\cup V, x_0)} π_1(B\cup U, x_0) \to π_1(X, x_0). \end{align*} $$
Then the theorem follows.