Let $R$ be a commutative ring with an $R$-module $M.$ Given any $R$-linear map $f : M \to M,$ consider the map $\cdot : R[X] \times M \to M$ defined by $r \cdot m = rm$ and $X \cdot m = f(m).$ By hypothesis that $f$ is $R$-linear, it follows that $X \cdot (m + m') = f(m + m') = f(m) + f(m') = X \cdot m + X \cdot m',$ hence $\cdot$ gives $M$ an $R[X]$-module structure that can be extended linearly to find $p(X) \cdot m$ for any element $p(X)$ of $R[X].$ (Check for yourself that the other properties work out.)
Given that $f : M \to M$ is surjective, it follows that for any element $m$ of $M,$ there exists an element $m'$ of $M$ such that $m = f(m') = X \cdot m'.$ Consquently, we have that $M \subseteq XM$ (here, we are suppressing the $\cdot$ notation for brevity). On the other hand, it is clear that $XM \subseteq M$: for any element $m$ of $M,$ we have that $X \cdot m = f(m)$ is in $M.$ We conclude that $XM = M.$
Last, we claim that $M$ is a finitely generated $R[X]$-module. By hypothesis that $M$ is a finitely generated $R$-module, there exist elements $m_1, \dots, m_n$ of $M$ such that every element $m$ of $M$ can be written as $m = r_1 m_1 + \cdots + r_n m_n$ for some elements $r_1, \dots, r_n$ of $R.$ By viewing the $r_1, \dots, r_n$ as constant polynomials of $R[X],$ it follows that $m = r_1 \cdot m_1 + \cdots + r_n \cdot m_n$ so that $M$ is a finitely generated $R[X]$-module. Consequently, by Nakayama's Lemma (applied to the finitely generated $R[X]$-module $M$ and the principal ideal $(X)$ of $R[X]$), there exists an element $p(X)$ of $(X)$ such that $(1_R + p(X)) M = 0.$ Can you finish the proof from here?