Consider the Jordan canonical form $Q = U J U^{-1}$ for $Q$. Thus $w^T Q w = \sum_B w_B^T B v_B$ for Jordan blocks $B$, where $w_B$ and $v_B$ are the entries of $U^T w$ and $U^{-1} v$ corresponding to the block. For a Jordan block $B$ of size $m$ corresponding to the eigenvalue $0$, $s (sI - B)^{-1}$ is upper triangular with $1$ on the main diagonal and $1/s^j$ on the $j$'th diagonal above that. If it is known (for particular $w$ and $v$) that a finite limit exists, all the terms in $1/s^j$ in $w_B^T s (sI-B)^{-1} v_B$ must cancel, leaving the same result that you would have for $B = 0$. On the other hand, for a Jordan block corresponding to a nonzero eigenvalue, the limit is $0$. Thus if $P$ is the projection on the generalized eigenspace for eigenvalue $0$, the limit, if it exists, is $w^T P v$.
$P$ can be obtained as a polynomial $g(A)$, where if the largest Jordan block for eigenvalue $0$ has size $m_0$, $g(0) = 1$ and $g^{(j)}(0) = 0$ for $j < m_0$, while for every other eigenvalue $\lambda$ with largest Jordan block of size $m_\lambda$, $g(\lambda) = \ldots = g^{(m_\lambda-1)}(\lambda) = 0$. Of
Of course, this is notcan't be numerically stable: eigenvalues that are exactly $0$ and those that are close to $0$ will produce very different results.