If $X$ is contractible, then there is a map $i:\{*\}\to X$ and a map $f:X\to\{*\}$ (where $\{*\}$ is the one point space) such that $if\simeq\mathbf 1_X$. If $x_1$ is any point of $X$, we can set $j:\{*\}\to X, j(*)=x_1$, and then, because we can concatenate homotopies and compose them with maps,
$$jf\simeq (if)jf=i(fj)f=if\simeq\mathbf 1_X$$
Let $X^{n+1}$ be the $n+1$-skeleton and $\Phi_{\alpha}\colon D_{\alpha}^{n+1}\rightarrow X^{n+1},\,\alpha\in A$ the $n+1$-cells. Then $X^{n+1}$ with the centers of the $n+1$-cells removed is the space $X^{n+1}\setminus\{\Phi_{\alpha}(0)\colon\alpha\in A\}$. This is the disjoint union of its subspaces $X^n=X^{n+1}\setminus\{\Phi_{\alpha}(\mathrm{int}(D_{\alpha}^{n+1}))\colon\alpha\in A\}$ (here, I'm identifying $X^n$ with its copy in $X^{n+1}$ as is usual) and $\Phi_{\alpha}(\mathrm{int}(D_{\alpha}^{n+1})\setminus\{0\}),\,\alpha\in A$. Let $H\colon(D^{n+1}\setminus\{0\})\times I\rightarrow D^{n+1}\setminus\{0\}$ be a strong deformation retraction of $D^{n+1}\setminus\{0\}$ onto $S^n$. Now, we want to construct a strong deformation retraction $\tilde{H}\colon(X^{n+1}\setminus\{\Phi_{\alpha}(0)\colon\alpha\in A\})\times I\rightarrow X^{n+1}\setminus\{\Phi_{\alpha}(0)\colon\alpha\in A\}$ of $X^{n+1}\setminus\{\Phi_{\alpha}(0)\colon\alpha\in A\}$ onto $X^n$. The idea is to push forward the homotopy $H$ through the $\Phi_{\alpha},\,\alpha\in A$ while leaving $X^n$ fixed, though some care needs to be taken at the boundaries.
Let us define $\tilde{H}(x,t)=x$ for $(x,t)\in X^n\times I$ and $\tilde{H}(x,t)=\Phi_{\alpha}(H(\Phi_{\alpha}^{-1}(x),t))$ for $(x,t)\in\Phi_{\alpha}(\mathrm{int}(D_{\alpha}^{n+1})\setminus\{0\})\times I,\,\alpha\in A$ (note that $\Phi_{\alpha}\vert_{\mathrm{int}(D_{\alpha}^{n+1})}\colon\mathrm{int}(D_{\alpha}^{n+1})\rightarrow X^{n+1}$ is a homeomorphism onto its image, whose inverse is what I mean by $\Phi_{\alpha}^{-1}$). By construction, $\tilde{H}(-,0)$ is the identity, $\tilde{H}(x,t)=x$ for any $(x,t)\in X^n\times I$ and $\tilde{H}(-,1)$ is a retraction of $X^{n+1}\setminus\{\Phi_{\alpha}(0)\colon\alpha\in A\}$ onto $X^n$ (since $\tilde{H}(\Phi_{\alpha}(\mathrm{int}(D_{\alpha}^{n+1})\setminus\{0\})\times\{1\})\subseteq\Phi_{\alpha}(S^n)\subseteq X^n$ for all $\alpha\in A$). It remains to check that $\tilde{H}$ is continuous.
By definition of the CW topology, there is a quotient map $X^n\sqcup\bigsqcup_{\alpha\in A}D_{\alpha}^{n+1}\rightarrow X^{n+1}$. Since $I$ is compact, $\left(X^n\sqcup\bigsqcup_{\alpha\in A}D_{\alpha}^{n+1}\right)\times I\rightarrow X^{n+1}\times I$ is a quotient map. Furthermore, $\left(X^n\sqcup\bigsqcup_{\alpha\in A}D_{\alpha}^{n+1}\right)\times I\cong(X^n\times I)\sqcup\bigsqcup_{\alpha\in A}(D_{\alpha}^{n+1}\times I)$ via the obvious map. Altogether, we obtain a quotient map $(X^n\times I)\sqcup\bigsqcup_{\alpha\in A}(D_{\alpha}^{n+1}\times I)\rightarrow X^{n+1}\times I$, which restricts to a quotient map $r\colon(X^n\times I)\sqcup\bigsqcup_{\alpha\in A}((D_{\alpha}^{n+1}\setminus\{0\})\times I)\rightarrow(X^{n+1}\setminus\{\Phi_{\alpha}(0)\colon\alpha\in A\})\times I$. Chasing the definitions, this is given by $r(x,t)=(x,t)$ for $(x,t)\in X^n\times I$ and $r(x,t)=(\Phi_{\alpha}(x),t)$ for $(x,t)\in(D_{\alpha}^{n+1}\setminus\{0\})\times I$. Since $r$ is a quotient map, it suffices to check continuity of $\tilde{H}\circ r$. By definition of the coproduct topology, it suffices to check the continuity of $\tilde{H}\circ r\vert_{X^n\times I}$ and $\tilde{H}\circ r\vert_{D_{\alpha}^{n+1}\setminus\{0\}\times I}$ for all $\alpha\in A$. For $(x,t)\in X^n\times I$, we have $\tilde{H}(r(x,t))=\tilde{H}(x,t)=x$, whence $\tilde{H}\circ r\vert_{X^n\times I}$ is simply the composition $X^n\times I\rightarrow X^n\rightarrow X^{n+1}$ of projection followed by inclusion, i.e. continuous. For $(x,t)\in(D_{\alpha}^{n+1}\setminus\{0\})\times I$, we have
$$\tilde{H}(r(x,t))=\tilde{H}(\Phi_{\alpha}(x),t)=\left.\begin{cases}\Phi_{\alpha}(x),&x\in S_{\alpha}^n,\\\Phi_{\alpha}(H(x,t)),&x\in\mathrm{int}(D^{n+1})\setminus\{0\}\end{cases}\right\}=\Phi_{\alpha}(H(x,t)).$$
In the last equality, we have used that $H$ is a strong deformation retraction.
Thus, $\tilde{H}\circ r\vert_{(D_{\alpha}^{n+1}\setminus\{0\})\times I}=\Phi_{\alpha}\circ H$ is continuous. In conclusion, $\tilde{H}$ is continuous and thus a strong deformation retraction.
Best Answer
The image of a retraction is always closed in that space (if the space is Hausdorff ) and the interior $B^2$ is not closed in $D^2$.
A proof using sequences: if $r: X \to A$ is a retraction, and $(a_n)_n$ in $A$ converges in $X$ to $x$, then $r(a_n) \to r(x)$ by continuity of $r$. Being a retraction, $r(a_n)=a_n$ and as limits are unique, $r(x)=x$ so that $x \in A$, and so $A$ is closed.