TITLE: Is whether a set is closed or not a local property?
QUESTION [18 upvotes]: If I want to show a topological subspace is closed in an ambient space, does it suffice to know what happens on an open cover of the ambient space? More specifically,

Let $X$ is a topological space with a given open cover ${ U_i }$. Suppose that $Z \subset X$ is a set such that $Z \cap U_i$ is closed in $U_i$ for all $i$. Does it follow that $Z$ is closed in X?

This is clearly true if there are finitely many ${ U_i }$. At first thought, it seems unlikely to be true in the infinite case, but I'm having trouble coming up with a suitable counter-example.

REPLY [14 votes]: $U_i \setminus (Z \cap U_i)$ is open in $U_i$, thus also open in $X$. Then $X \setminus Z = \cup_ {i \in I} U_i \setminus (Z \cap U_i)$ is open in $X$, i.e. $Z$ is closed in $X$.