The question is stated clearly in the title. On the one hand, it seems obvious (and I give an argument below). On the other hand, after a quick search I haven't been able to find the statement anywhere (statements of this kind mostly focus on trace 0 functions on a domain with Lipschitz boundary), so I worry that the statement may be wrong and that I may be missing something in my argument. The argument is as follows:
Suppose $u\in W^{1,2}(\mathbb R^n)$ is a compactly supported function. Let $\omega$ be a mollifier, write $\omega_m(x):=m^n\omega(mx)$ for each $x\in\mathbb R^n$, and define $u_m:=u*\omega_m$. Since $u,\omega_m$ are compactly supported, then so is each $u_m$. Thus $\{u_m\}\subset C_0^{\infty}(\mathbb R^n)$. Moreover, $Du_m=(Du)*w_m$, so that $Du_m\rightarrow Du$ in $L^2(\mathbb R^n)$ as $m\rightarrow\infty$. Therefore,
$$ u_m\longrightarrow u\quad\text{in }W^{1,2}(\mathbb R^n)~~\text{as }m\rightarrow\infty $$ which implies the desired result.