From Intro to Topological Manifolds by Lee. I am confused about the proof of the closed subset part, which starts at line $4$ of the proof.
If $\overline{U \cap Z}$ is compact in $\bar U$, how does it follow that $\overline{U \cap Z}$ is compact in $Z$?

Compactness is an absolute, not relative property, in the following sense:
(1). A space $W$ is compact iff every cover of $W$ by open subsets of $W$ has a finite sub-cover.
(2). A sub-space $W$ of a space $Y$ is compact in $Y$ iff every cover of $W$ by open sets of $Y$ has a finite sub-cover.
(3). The important point is that a space $W$ is compact iff $W$ is compact in any space $Y$ of which $W$ is a sub-space.
So if $\overline {U\cap Z}$ is compact in $\overline U$ then the $space $ $\overline {U\cap Z}$ is compact, and it is a sub-space of $\overline Z=Z,$ so it is compact in $Z.$
This implicitly uses (twice) the transitivity of the relation "sub-space": If $B$ is a sub-space of $X$ and if $C$ is a sub$set$ of $B$ then the topology on $C$ as a sub-space of $B$ is equal to the topology on $C$ as a sub-space of $X$.... (With $C=\overline {U\cap Z}$ and with $B=\overline U$ or with $B=\overline Z$.)