STANDING ASSUMPTIONS: Let $T:D_T\rightarrow X$ be a linear operator, where $X$ is a normed space (or metrizable TVS) and $D_T\subset X$.
DEFINITION: Then $\lambda$ belongs to the resolvent set $\rho(T)$ iff $T-\lambda I$ is one-to-one and onto and its inverse is bounded.
LEMMA. A linear operator $T$ in a normed space $X$ is closed if$^\dagger$ it has a non-empty resolvent set.
PROOF. Let $D_T\owns x_n\rightarrow x$, $Tx_n\rightarrow y$.$^\ddagger$ Let $\lambda$ be in the resolvent set. Then $x=\lim_n x_n = \lim_n (T-\lambda)^{-1}(T-\lambda)x_n=(T-\lambda)^{-1}(y-\lambda x)$ (+).
Therefore, $x\in (T-\lambda)^{-1}(X)=D_T$.
By (+), $(T-\lambda)x=(T-\lambda)(T-\lambda)^{-1}(y-\lambda x)=(y-\lambda x)$;
hence $Tx=y$, so $T$ is closed, QED.
Note: Robert Israel's shorter proof on this page shows the same for any TVS (if you require that the inverse is a continuous operator). The above proof (that works for all metrizable TVSs) might be easier for some readers.
$\dagger$) The "if" in the lemma cannot be reversed, as some closed operators (even on $\ell^2$) have an empty resolvent set, by https://math.stackexchange.com/questions/3262168/closed-operator-with-trivial-resolvent-set
$\ddagger$) In a metrizable space, a set is closed iff it is sequentially closed. So the graph $G_T:=\{(x,Tx):\, x\in D_T\}$ is closed iff $G_T\owns (x_n,Tx_n)\rightarrow (x,y)\ \Rightarrow\ (x,y)\in G_T$ (i.e., $x\in D_T$ and $y=Tx$).
Note that your assumption that the operator is densely defined was not needed. This is a strict improvement:
EXAMPLE. Let $L$ denote the inverse of the right-shift $R:(x_1,x_2,\cdots)\rightarrow (0,x_1,x_2,\cdots)$. Then dom$L=R(\ell^2)$ is not dense, as $(1,0,0,\cdots)$ is not in its closure, but yet the (onto-)resolvent set $\rho(L)$ is nonempty, as $(L-0)^{-1}=R$ and hence $0\in\rho(L)$.
This "onto" definition seems to be standard:
Rudin: F.A., 13.26 &
https://en.wikipedia.org/wiki/Spectrum_(functional_analysis)#Spectrum_of_an_unbounded_operator
Your claim is true only for this standard definition ("onto"), not for the older definition ("dense range" in place of "onto"), by Matthew Daws' example. For closed operators, the two definitions are equivalent. For a further discussion on this and the two definitions, see: Standard definition of a resolvent: A-zI must be onto, not merely have a dense range?