Suppose $Z \subset X \times Y$ is closed, and suppose $x_0 \in X \setminus \pi[Z]$.
For any $y \in Y, (x_0, y) \notin Z$, and as $Z$ is closed we find a basic open subset $U(y) \times V(y)$ of $X \times Y$ that contains $(x_0, y)$ and misses $Z$.
The $V(y)$ cover $Y$, so finitely many of them cover $Y$ by compactness, say $V(y_1),\ldots,V(y_n)$ do. Now define $U = \cap_{i=1}^{n} U(y_i)$, and note that $U$ is an open neighbourhood of $x_0$ that misses $\pi[Z]$. So $\pi[Z]$ is closed.
To see that the closed projection property implies compactness (sketch): suppose $X$ has the closed projection property along $X$, and let $\cal{F}$ be a filter on $X$. Define a space $Y$ that is as a set $X \cup \{\ast\}, \ast \notin X$, where $X$ has the discrete topology and a neighbourhood of $\ast$ is of the form $A \cup \{\ast\}$ with $A \in \cal{F}$. Then $D = \{(x,x): x \in X\}$ is a subset $X \times Y$ and closedness of the projection $p: X \times Y \rightarrow Y$ implies that some point $(x,\ast)$ is in its closure, and this $x$ is an adherence point of the filter.