Claim: a continuous function $f: \mathbb{R} \rightarrow \mathbb{R}$ is closed iff for $\alpha=\pm \infty$, as $x \rightarrow \alpha$, $f(x)$ is eventually constant or goes to infinity.
Proof: for $\Rightarrow$, we focus on the case $\alpha=\infty$. Assume $f$ is closed. Let $x_n$ be a sequence of real numbers going to infinity, then $\{f(x_n)|n \geq 1\}$ is closed. In particular, if $\ell \in \mathbb{R}$ is a limit point of $(f(x_n))_n$, then we must have $f(x_n)=\ell$ for infinitely many $n$.
Suppose $f \rightarrow \ell \in \mathbb{R}$, then the above shows that $f$ is eventually constant.
The set of limit points of $f$ at $\infty$ is an interval, so if $f$ is not eventually constant or does not go to infinity, there are $\ell \in \mathbb{R}$, $\epsilon >0$ such that every point of $[\ell-\epsilon,\ell+\epsilon]$ is a limit point of $f$. In particular, we can find a sequence $x_n \rightarrow \infty$ such that $f(x_n) \in [\ell+\epsilon/3^{n+1},\ell+2\epsilon/3^{n+1}]$, so that $f(x_n) \neq \ell$ for every $n$ but $f(x_n) \rightarrow \ell$. QED.
For $\Leftarrow$, we can check that a continuous $f$ is closed if $f$ and $f(-\cdot)$ are closed as functions $[0,\infty) \rightarrow \mathbb{R}$. So we’re reduced to showing that a continuous function $f:[0,\infty) \rightarrow \mathbb{R}$ is closed if it is eventually constant or it goes to $\infty$. Both cases are easy to see (the second, because $f$ is proper – the pre-image of a compact is compact – which is a stronger condition in eg metrizable spaces).
So the goal is to show that
- any neighborhood of $0$ contains non-closed functions.
- any non-closed function has a neighborhood consisting only of non-closed functions.
For 2), by definition of the topology, we can work in $C^0_S$. We’ll focus only on behavior at $\infty$, and the types of singularity, leaving how to recompose them to the careful reader.
We can split into two cases, for $g$ a non-closed continuous function:
2a. $g$ converges to some finite $\ell$ but is not eventually constant.
2b. $g$ has more than one limit point at $\infty$.
In case 2b, $g$ has two distinct finite limit points $a$ and $b$. Let $\frac{|a-b|}{2} > \epsilon > 0$, then every function in $\{h| |h-g| <\epsilon\}$ has more than one finite limit point at $\infty$ so is non-closed.
In case 2a, there is a sequence $x_n$ such that $x_{n+1} > x_n+1$ such that $\delta_n=|f(x_n)-\ell| > 0$. Then $\{h| \forall n\forall y \in [x_n-1/2,x_n+1/2],\, |h-g|< \delta_n\}$ is open, any function $h$ in this set is such that $h(x_n) \neq \ell$, $h(x_n) \rightarrow \ell$, so is non-closed.
Regarding 1): it’s enough to show that for any $r \geq 0$, and any positive sequence $\epsilon_n$ going to zero, $U_{r,\epsilon}=\bigcap_{n,0 \leq s \leq r}{\{h| \forall y,\, n \leq |y| \leq n+1 \Rightarrow |h^{(s)}(y)| \leq \epsilon_n\}}$ contains a smooth function that is not stationary at zero.
Let $\chi$ be a smooth even non-negative function with support in $(-1/4,1/4)$ such that $\chi(0)=1$ and $s_n$ be a positive sequence with $(1+\|\chi\|_{C^r})s_n < \min_{1 \leq t \leq n+2}\,\epsilon_t$.
Define $\psi(x)$ by: if $x \in [n-1/2,n+1/2]$, $n \neq 0$, $\psi(x)=s_{|n|}\chi(x-n)$ (and $\psi(x)=0$ for $|x| \leq 1/2$). Then $\psi \in U_{r,\epsilon}$ and $\psi$ converges to zero, but $\psi$ is not stationary so isn’t closed.