In Lee Smooth Manifolds, this problem is given:
if $S \subset M$ is smoothly embedded and every $f \in \mathcal{C}^{\infty}(S)$ extends to a smooth function on $\textit{all}$ of $M$, then $S$ is properly embedded.
Properly embedded means the inclusion $i: S \to M$ is proper. For this we have to show $S$ is closed or it's a level set of a continuous function.
I think it should be just a few lines, but I am totally stuck for two hour! Please to help, thanks =)
What I tried: Since $S$ is embedded, it can be covered with slice charts $U_p$. If $V = \cup U_p$ then with bump functions we can make $S$ closed in $V$ by making it a level set. But $V$ is open, so it does not mean $S$ is still closed in the whole manifold. I could not alter this into proof.
I also tried to make an extension of the identity map of $S$, so that then $S$ would be a retract and closed.