Let $X$ and $Y$ be topological spaces such that $Y$ is compact, and let $f \colon X \to Y$ be a closed, surjective, and continuous map such that, for each $y \in Y$, the inverse image $f^{-1} ( \ \{y \} \ )$ is compact.
Then how to show that $X$ is compact also?
My effort: (A Mere Write-Up / Presentation Of The Proof Based On The Answers Below)
Let $\mathscr{A}$ be an open covering of $X$. Then, for each $y \in Y$, the collection $\mathscr{A}$ is a covering of $f^{-1} ( \ \{y\} \ )$ by sets open in $X$, and since $f^{-1} ( \ \{y\} \ )$ is compact, some finite subcollection of $\mathscr{A}$, say $\mathscr{A}_y$, also covers $f^{-1} ( \ \{y\} \ )$. That is, for each $y \in Y$, there exists a finite subcollection $\mathscr{A}_y$ of $\mathscr{A}$ such that $$ f^{-1} ( \ \{ y \} \ ) \subset \bigcup_{A \in \mathscr{A}_y } A. \tag{0} $$ For each $y \in Y$, let us put $$ U_y \colon= \bigcup_{A \in \mathscr{A}_y } A, \qquad \mbox{ and } \qquad C_y \colon= X \setminus U_y. \tag{A} $$ Then $U_y$ is an open set in $X$ and $C_y$ is a closed set; moreover we also have $$ f^{-1} ( \ \{ y \} \ ) \subset U_y, \tag{1} $$ and so $$ f^{-1} ( \ \{ y \} \ ) \cap C_y = \emptyset. \tag{2} $$ Now as $f \colon X \to Y$ is a closed map and as $C_y$ is a closed set in $X$, so the image set $f \left( C_y \right)$ is a closed set in $Y$. Let us put $$ W_y \colon= Y \setminus f \left( C_y \right). \tag{B} $$ Then $W_y$ is an open set in $Y$.
Now if $x \in f^{-1}\left( W_y \right)$, then by definition $x \in X$ is such that $f(x) \in W_y$, which implies that $f(x) \not\in f \left(C_y \right)$, [Refer to (B) above.] and so $x \not\in C_y$, which in turn implies that $x \in U_y$. [Refer to (A) above.] Therefore we have $$ f^{-1} \left( W_y \right) \subset U_y. \tag{3} $$
As $f$ is surjective, so, for each $y \in Y$, the set $f^{-}( \ \{ y \} \ )$ is non-empty, that is, there exists at least one $x_y \in X$ for which $$ y = f \left( x_y \right). \tag{4} $$ Any such $x_y \in f^{-1}( \ \{ y \} \ )$ of course, and so any such $x_y \not\in C_y$ because of (2) above.
So if $y \in f \left( C_y \right)$, then $y = f(v)$ for some element $v \in C_y$, which would imply that $v \in f^{-1}( \ \{ y \} \ ) \cap C_y$, which contradicts (2) above. Thus $y \not\in f \left( C_y \right)$, and therefore $ y \in W_y$. [Refer to (B) above.]
Thus we have shown that, for each $y \in Y$, there exists an open set $U_y$ in $X$ and there exists an open set $W_y$ in $Y$ such that $$ y \in W_y \ \qquad \mbox{ and } \qquad f^{-1} \left( W_y \right) \subset U_y; \tag{5} $$ [Refer to (3) above.] moreover the set $U_y$ is the union of some finite subcollection $\mathscr{A}_y$ of the open covering $\mathscr{A}$ of $X$. [Refer to (0) above.]
In this way, we obtain an open covering of $Y$, which is as follows: $$ \left\{ \ W_y \ \colon \ y \in Y \ \right\}. $$ And, since $Y$ is compact, this open covering has a finite subcollection that also covers $Y$; let $$ \left\{ \ W_{y_1}, \ldots, W_{y_n} \ \right\} $$ be this finite subcollection. Then we have $$ Y = \bigcup_{j=1}^n W_{y_j}. \tag{6} $$
Now we show that $$ X = \bigcup_{j=1}^n U_{y_j}. \tag{7} $$ Let $x$ be an arbitrary point of $X$. Let $y \colon= f(x)$. Then $y \in Y$, and so by (6) above we have $y \in W_{y_k}$ for at least one $k = 1, \ldots, n$; that is, $f(x) \in W_{y_k}$; this implies that $x \in f^{-1} \left( W_{y_k} \right)$ and hence $x \in U_{y_k}$, because of (3) above; therefore $$ x \in \bigcup_{j=1}^n U_{y_j}. $$ Thus one of the inclusions required for (7) above to hold holds; the other inclusion follows from the fact that, by our construction of these sets, each set $U_{y_j}$, for $j = 1, \ldots, n$, being a union of subsets of $X$, is itself a subset of $X$. [Refer to (0) and (1) above.]
Finally, as $X$ is a union of the collection $\left\{ \ U_{y_1}, \ldots, U_{y_n} \ \right\}$ consisting of finitely many sets and as each set $U_{y_j}$, for $j = 1, \ldots, n$, in this collection is itself a union of a finite subcollection $\mathscr{A}_{y_j}$ of our original open covering $\mathscr{A}$ of $X$ [Refer to (A) above.], so we can conclude that $X$ is eventually the union of the finite subcollection $\mathscr{A}_{y_1} \cup \ldots \cup \mathscr{A}_{y_n}$ of $\mathscr{A}$.
Since $\mathscr{A}$ is an arbitrary open covering of $X$, we can conclude that $X$ is compact.
Is my write-up correct? If so, then is it clear and easy enough to understand? If not, then where are the problems?