This Question gives the following argument for why the retract of a Hausdorff space is closed:
Proof. Let $x∉A$ and $a=r(x)∈A$. Since $X$ is Hausdorff, $x$ and $a$ have disjoint neighborhoods $U$ and $V$, respectively. Then $r^{−1}(V∩A)∩U$ is a neighborhood of $x$ disjoint from $A$. (*) Hence, $A$ is closed.
It looks to me like this presumes that every $x∉(X-A)$ has an neighborhood, $U$, that doesn't intersect $A$. Otherwise $r^{−1}(V∩A)∩U$ could be in $A$, and the proof wouldn't work. It seems to me though that the only way every $U$ could not intersect $A$ is if we've already assumed that $A$ is closed because otherwise there would be a point in the boundary of $A$, but not in $A$, and every neighborhood of this point would intersect $A$. And so we wouldn't be able to find a neighborhood, $U$, of this point that doesn't intersect $A$.
So does this proof actually work and I've missed something?
We need to show that for each $x \in X \setminus A$ there is an open neighbourhood $U$ of $x$ which is disjoint from $A$ (this then implies that $X \setminus A$ is open, and so $A$ is closed). Below is the proof spelled out in quite a bit of detail.
Now given any $x \in X \setminus A$, since $r$ is a retraction onto $A$ we have that $r(x) \in A$, and so in particular $r(x) \neq x$. Since $X$ is Hausdorff we know that there are disjoint open sets $V , W$ about $x$ and $r(x)$, respectively. Since $r$ is continuous, it follows that $r^{-1} [ W ]$ is open, and since $r(x) \in W$ we have that $x \in r^{-1} [ W ]$; so $U = V \cap r^{-1} [ W ]$ is also an open neighbourhood of $x$.
Can $U$ intersect $A$? Well, if $y \in U$, then it must be that $r(y) \in W$, and since $V$ and $W$ are disjoint we have that $r(y) \notin V$, but since $y \in V$ it follows that $y \neq r(y)$, and so $y \notin A$. Therefore $U$ is an open neighbourhood of $x$ which is disjoint from $A$.
Notice that above we have only used the assumption that $r$ is a retraction onto $A$ (so $r$ is continuous, and $f(x) \in A$ for all $x \in X$, and $r(a) = a$ for all $a \in A)$, and that $X$ is Hausdorff (so different points can be separated by disjoint open neighbourhoods). What we do is construct from these assumptions an open neighbourhood of $x$ disjoint from $A$.