Another way to look at this involves frequency domain aliasing due to time-domain sampling of a non-bandlimited function. The prototypical continuous-time Hann window function is (Fig. 1):
$$f(x) = \cases{\frac{1}{2}-\frac{1}{2}\cos(\pi x)&if $-1 < x < 1,$\\0&otherwise.}$$
Figure 1. The prototypical continuous-time Hann window function.
It is related to your $w(n)$ by:
$$w(n) = f\left(\frac{2n}{N-1}-1\right).$$
The Fourier transform (with angular frequency $\omega$) of $f(x)$ is:
$$\begin{align}F(\omega) &= \int_{-1}^{1}f(x)e^{-i\omega x}\\&= \int_{-1}^{1}\frac{1}{2}(1-\cos(2\pi x))e^{-i\omega x}\\&= \frac{1}{2}\operatorname{sinc}(\omega+\pi) + \operatorname{sinc}(\omega) + \frac{1}{2}\operatorname{sinc}(\omega-\pi),\end{align}$$
with this convenience definition of the sinc function (often you'd see $\pi \omega$ instead of $\omega$):
$$\operatorname{sinc}(\omega) = \cases{1 &if $\omega = 0,$\\
\frac{\sin(\omega)}{\omega}&otherwise.}$$
The Fourier transform consists of shifted and scaled sinc functions, because $f(x)$ is the product of three complex exponential functions (complex sinusoids) and a rectangular function. The frequency domain counterpart of this is convolution of a sum of three shifted and scaled Dirac delta functions by a sinc function. The sinc function (by the above definition) is zero-valued at all integer multiples of $\pi$ except for at $\omega = 0$, and nowhere else. Likewise, $F(\omega)$ is zero-valued at integer multiples of $\pi$ except for at $\omega \in \{-\pi, 0, \pi\}$, and nowhere else (Fig. 2):
Figure 2. Absolute value of the Fourier transform of the prototypical continuous-time Hann window in dB scale. The horizonal axis is shown in multiples of $2\pi.$ All notches are true zeros.
The tails of $F(\omega)$ go on forever, so $f(x)$ is not bandlimited. When $f(x)$ is sampled this will result in frequency domain aliasing. If $f(x)$ was sampled directly with a sampling period of $1$, the aliasing would be around Nyquist frequency $\omega = \pi$ (the first gray gridline), but based on Eq. 1, you are sampling it more densely with a period $\frac{2}{N-1}$ in $x$, which means aliasing around $\omega =$ $ \pi/\frac{2}{N-1} =$ $ (N-1)\frac{\pi}{2}.$ As long as $N$ is an integer, all unaliased zeros will coincide with aliased zeros. They will thus remain zeros. For example $N = 9$ sees aliasing around $\omega=4\pi$ (Fig. 3):
Figure 3. Aliased spectrum of a sampled Hann window $w(n)$ with $N = 9$. The horizontal axis is the angular frequency $\omega$ with respect to $x$ shown in multiples of $2\pi.$
Because $f(x)$ was defined for the complete real line, the sampled window $w(n)$ is zero-padded both ways to eternity. Its aliased spectrum illustrated in Fig. 3 will be sampled by the discrete Fourier transform (DFT) with a uniform grid of $M$ samples inclusive of the first sample at $\omega = 0$ and exclusive of a one-beyond-last sample at the sampling frequency $\omega = (N-1)\pi.$ Considering that zeros still appear only at values of $\omega$ that are integer multiples of $\pi$, if the factor $M / (N-1)$ is an integer, then all the zeros of the spectrum will be included in the frequency sampling, resulting in your second figure (Hanning window 500). Otherwise, DFT might miss (sometimes barely) some of the zeros. Looks like you had $N=51$, because $500/50 = 10$ is an integer.