You have a symmetric operator $P$. That is, $(Pf,g)=(f,Pg)$ for all $f,g \in \mathcal{D}(P)$. A general method for showing that a symmetric operator $P$ is densely-defined and selfadjoint is to show that $(P\pm iI)$ are surjective, which is easy to apply in your case because, for all $g \in L^{2}(\mathbb{R})$, one has $\frac{1}{x\pm i}g \in L^{2}$ and $(P\pm iI)((x\pm i)^{-1}g) =g$.
Theorem: Let $P : \mathcal{D}(P)\subseteq H\rightarrow H$ be a symmetric linear operator on a complex Hilbert space $H$. Then $P$ is densely-defined and selfadjoint if $P\pm iI$ are surjective.
Proof: Let $P$ be as stated and suppose that $P\pm iI$ are surjective. Then $\mathcal{D}(P)$ is dense iff $\mathcal{D}(P)^{\perp}=\{0\}$. So, suppose $h \perp \mathcal{D}(P)$. Then $h=(P+iI)g$ for some $g\in\mathcal{D}(P)$, which gives
$$
0 = \Im (h,g)= \Im ((P+iI)g,g) = \|g\|^{2}.
$$
Hence, $g=0$, which proves that $\mathcal{D}(P)$ is dense.
Therefore $P^{\star}$ is closed and densely-defined. And $P^{\star}$ is an extension of $P$ because $P$ is symmetric. To show that $P=P^{\star}$, it is enough to show that $\mathcal{D}(P^{\star})\subseteq \mathcal{D}(P)$. Let $g \in \mathcal{D}(P^{\star})$. By assumption, $(P^{\star}+iI)g=(P+iI)h$ for some $h\in\mathcal{D}(P)$. Therefore, for all $f \in \mathcal{D}(P)$,
\begin{align}
((P-iI)f,g) & = (f,(P^{\star}+iI)g) \\& =(f,(P+iI)h)=((P-iI)f,h)
\end{align}
So $g-h \perp \mathcal{R}(P-iI)=H$, which gives $g = h \in\mathcal{D}(P)$. $\;\;\Box$