Is there a mistake in the proof given or did I misunderstand what has to be shown?
Prop. Suppose $(X, \tau_{X})$ is a compact Hausdorff space and $(Y, \tau_{Y})$ is a Hausdorff space such that $X \subseteq Y$. Then, $X$ is closed in $Y$.
Proof. Let $(X, \tau_{X})$ be a compact Hausdorff space and $(Y, \tau_{Y})$ be a Hausdorff space such that $X \subseteq Y$.
We want to show that $X$ is closed in $Y$ $\iff$ $X^{\complement} = Y \setminus X$ is open in $Y$ $\iff$ for each $y \in Y \setminus X$ there is an open neighborhood $U_{y}$ of $y$ such that $U_{y} \subseteq X^{\complement}$.
So let $y \in X^{\complement} = Y \setminus X$ be arbitrary. Then, $y \in Y$ and $y \notin X$. Since $Y$ is Hausdorff, for any $x \in X$ (note that $y \neq x$ since $y \notin X$) there is an open neighborhood $U_{x}$ of $x$ and there is an open neighborhood $U_{y}$ of $y$ such that
$$U_{x} \cap U_{y} = \emptyset.$$
Our goal is to show that $U_{y} \subseteq X^{\complement} = Y \setminus X$ i.e. each $y \in U_{y}$ implies $y \in Y$ and $y \notin X$.
But each $x$ has such an open neighborhood $U_{x}$ i.e. $\{ U_{x} \}$ is an open cover of $X$. By compactness of $X$ there is a finite subcover of $\{ U_{x} \}$ which covers $X$.
This is where I was stuck and looked at the book. The book then proceeds by saying
Take $U_{y}$ to be the intersection of all the open neighborhoods of $y$. Then, $U_{y}$ is an open neighborhood of $y$ which does not intersect the finite open subcover $\{ U_{x}^{\iota} \}_{\iota = 1}^{n}$. And hence $y \notin \bar{X}$. It follows that $X$ is closed in $Y$.
Shouldn't this be: And hence $y \notin X$? Or how is the closure $\bar{X}$ of $X$ involved in the proof?
The proof is correct. It uses that for any $A \subseteq X$,
$$\overline{A}=\{x \in X: \forall U \text{ open in } X : x \in U \to U \cap A\neq \emptyset \}$$
i.e. the closure is the set of adherence points. Always $Y \subseteq \overline{Y}$ and the proof shows (the $U_y$ is a witnessing open set for this) that $y \in Y^\complement$ is not an adherence point, so $Y^\complement \subseteq \overline{Y}^\complement$ so by contrapositive $\overline{Y} \subseteq Y$ and so $Y=\overline{Y}$ and $Y$ is closed.