Call a continuous function $\phi: A \to B$ universally closed if $\phi \times 1_T$ is closed for every topological space $T$. Exercise 3.6.13(d) of Ronnie Brown's Topology and Groupoids asks the reader to show that if $f: X \to Y$ and $g: Y \to Z$ are continuous functions, $gf$ is universally closed, and $Y$ is Hausdorff, then $f$ is universally closed.
In previous exercises it has been shown that $\phi$ universally closed is equivalent to $\phi$ being closed with compact fibers. Also it has been shown that $\phi$ universally closed implies that $\phi$ is proper, i.e. preimages of compact sets are compact. Also could be useful: a map from a compact space to a Hausdorff space is universally closed, and a proper map into a Hausdorff $k$-space is universally closed.
My strategy has been to show that $f$ is closed with compact fibers. I have succeeded in showing that $f$ must have compact fibers, but I have not been able to show $f$ is closed.
The argument for compact fibers is: Suppose $y \in Y$. Then $(gf)^{-1}g(\{y\})$ is compact, since it is the preimage under $gf$ of the compact set $\{g(y)\}$. The point set $\{y\}$ is closed since $Y$ is Hausdorff, so $f^{-1}(\{y\})$ is a closed set, because $f$ is continuous. Since $f^{-1}(\{y\})$ is a closed subset of the compact set $(gf)^{-1}g\{y\}$, it is itself compact. QED
Note that the same argument works for $\{y\}$ replaced by any compact set, so $f$ is surely proper. As mentioned, a proper map into a Hausdorff $k$-space is universally closed, so if we can show that $Y$ is a $k$-space, we'd be done, but I don't see why it should be.

The following is an adaptation from Bourbaki's General topology, Ch. I, §10, Prop. 5. I will be using parts (a) and (c) of your exercise, namely:
(a) if $f,g$ are universally closed and $\operatorname{Im} f$ is closed, then $g \circ f$ is universally closed;
(c) if $g \circ f$ is universally closed and $g$ is injective then $f$ is universally closed.
Consider the commutative diagram $$\require{AMScd} \begin{CD} X @>{\Gamma_f}>> X \times Y\\ @V{f}VV @VV{(g \circ f) \times \operatorname{Id}_Y}V\\ Y @>{\Gamma'_g}>> Z \times Y \end{CD}$$ where $\Gamma_f$ is the graph of $f$ mapping $x \mapsto (x,f(x))$ and $\Gamma'_g$ is the mapping $y \mapsto (g(y),y)$.
First, $\Gamma_f(X)$ is a homeomorphism onto its image since the first projection is a continuous inverse map. Next, $\Gamma_f(X)$ is closed in $X \times Y$ since if $\Delta_Y \colon Y \to Y \times Y$ is the diagonal, then $\Gamma_f(X) = (f\times\operatorname{Id}_Y)^{-1}(\Delta_Y(Y))$, and $\Delta_Y(Y)$ is closed. Thus $\Gamma_f$ is a closed map with compact fibres hence universally closed.
Now by assumption, $(g \circ f) \times \operatorname{Id}_Y$ is universally closed (since if $W$ is another topological space, then $(g \circ f) \times \operatorname{Id}_Y \times \operatorname{Id}_W = (g \circ f) \times \operatorname{Id}_{Y \times W}$ is closed), so the composition $X \to Z \times Y$ is universally closed by (a). Thus, since $\Gamma'_g$ is injective, $f$ is universally closed by (c).