I was looking at the following reaction and am confused.
It appears that $\ce{N}$ is attacking the $\ce{C-Cl}$ and $\ce{Cl}$ is leaving in a $\mathrm{S_N2}$ reaction. I know that $\ce{Cl}$ is a good leaving group, but $\ce{N}$ isn't a particularly soft nucleophile so I wouldn't expect it to be great at attacking a saturated carbon.
Additionaly there is $\ce{MeO-}$ in solution, even with intramolecular cyclisation being quick wouldn't there be a realitive amount of attack by $\ce{MeO-}$.
So am I missing something? Is this not as simple an $\mathrm{S_N2}$ as I have made out? Why is sodium methoxide ($\ce{NaOMe}$) a good choice of base?