We prove that the number of curves of a fixed genus g over finite fields is a polynomial function of the size of the field if and only if g is at most 8. Furthermore, we determine for each positive genus g the smallest n such that the moduli space of curves of genus g with n marked points does not have polynomial point count. A key ingredient in the proofs, which is also a new result of independent interest, is the computation of the thirteenth cohomology group of the moduli spaces of stable curves of genus g with n marked points, for all g and n.