The total charge is only defined on a spatial slice, but on any compact spatial slice your argument shows that the total charge is zero. A nice way of imagining this is to ask yourself "in the case of some charge excess, where would the extra field lines go?"

By the way, this fact can actually be violated in the case where there is some ABJ anomaly. For example in the background of a flat photon field one doesn't see any chiral current non-conservation, but if one considers the total charge on a compact spatial slice where the photon field has a non-trivial Chern-Simons invariant, then this invariant equals the total charge! This is a global manifestation of the chiral anomaly.