Problem. Let $(X,\mathcal{T}_X)$ and $(Y,\mathcal{T}_Y)$ be two topological spaces and $f,g:X\to Y$ such that $f$ and $g$ both are continuous on $X$. Show that the set $E:=\{x:f(x)=g(x)\}$ is closed in $X$.
My Attempt
Let $\mathscr{S}:=\{V:(V\ \text{is closed in}\ Y)\land ((f(x)=g(x))\implies f(x)\in V)\}$. If $\mathscr{S}=\emptyset$ then we have nothing to prove since then $E=\emptyset$ and is indeed closed in $X$. So let $\mathscr{S}\ne \emptyset$. Then observe that,
$\displaystyle\bigcap_{\alpha\in \mathscr{S}}V_\alpha$ is the smallest closed set in $\mathscr{S}$.
$\displaystyle\bigcap_{\alpha\in \mathscr{S}}V_\alpha\subseteq f(X)$
Now observe that, $$f(x)\in f(E)\implies f(x)=g(x)\implies f(x)\in \displaystyle\bigcap_{\alpha\in \mathscr{S}}V_\alpha$$
At this point I am stuck. I actually wanted to show that $f(E)=\displaystyle\bigcap_{\alpha\in \mathscr{S}}V_\alpha$ but I am unable to do that. So my questions are,
Is there any way to show that $f(E)=\displaystyle\bigcap_{\alpha\in \mathscr{S}}V_\alpha$?
If not, then can some other way of proving this result be suggested?