I want to prove that if $f,g$ are continuous functions from a topological space $(X,\tau)$ to a metric space $(Y,d)$ then the set
$$ A = \{ x \in X : f(x) = g(x) \} $$
is closed. I found a very similar question asked on this site but it referred to Hausdorff spaces, which I haven't quite met. I know I can prove this by proving that the complement of $A$ is open. If I consider $b \in X$ such that $f(b) \neq g(b)$, then I can find two open sets $U,V \subseteq Y$ such that $f(b) \in U $, $\ g(b) \in V$ and $U \cap V = \varnothing$. Then since the functions are continuous we must have that $f^{-1}(U)$ and $g^{-1}(V)$, which both contain $b$, are open. Hence so is their intersection.
Now I'm not sure how to proceed...
EDIT: Whilst there are neater methods in the answers, I've just realised how I can finish the proof above. The intersection
$$ W_b = f^{-1}(U) \cap g^{-1}(V)$$
lies entirely outside $A$ --- one can show this by supposing that there exists some $a \in A$ that is a member of $W_b$ and showing that $f(a) \in U$ and $g(a) \in V$. But $f(a) = g(a)$ by the assumption that $a \in A$, which is impossible since $U \cap V = \varnothing$.
Then the union
$$ \bigcup_{b \in X \setminus A} W_b$$
is a union of open sets and hence open, contains all $b \in X \setminus A$, and does not intersect with $A$ since $W_b \cap A = \varnothing$. Hence the union above is precisely $X \setminus A$, and hence $A$ is closed.
If $Y$ is a metric space, the set $\Delta =\{(y,y):y\in Y\}$ is closed in $Y\times Y$ -- this holds more generally iff $Y$ is Hausdorff (can you prove this?). Observe now that $$A=\{x\in X:f(x)=g(x)\}$$ equals the set $$B=\{x\in X:h(x)\in \Delta\}=h^{-1}(\Delta)$$ where $h:X\to Y\times Y$ is defined by $h(x)=(f(x),g(x))$. But $\Delta$ is closed, and $h$ is continuous. This proves the more general case where $Y$ is Hausdorff.