It is not true that $G_f = M \times f(M)$. Take for example the identity on $\mathbb{R}$, in which case
$$
G_{id} = \Delta = \{(x,x) : x \in \mathbb{R}\} \neq \mathbb{R} \times \mathbb{R} = M \times id(M).
$$
Hint: a set is closed if limits of nets (or sequences if your space is metric) on the space that converge, are elements of the space itself. Take an arbitrary convergent net (or sequence) on $G_f$. Use that projections are continuous (and the equivalence of continuity that is related to sequences/nets). Conclude that the limit point are elements of $G_f$.
Since you mention that there is no treatment of topological spaces which aren't metric, here's a solution for the case of metric spaces:
Take $\{(x_n,f(x_n))\}_n$ a sequence on $G_f$ that converges to some element $(s,t)$. By continuity of $\pi_1$, we have that $x_n \to s$. By continuity of $f$, we have $f(x_n) \to f(s)$. Since we also have $f(x_n) \to t$, necessarily $t = f(s)$ and so $(s,t) = (s,f(s)) \in G_f$.