The plural of "quiz" is spelled with double "z" while the plural of "box" (and sometimes "bus") is spelled with a single last consonant. Why is it so? Is this the general rule to double the last consonant to keep the syllable closed?
In most cases where a word ends in (vowel)-(consonant)-e, we pronounce the last syllable with a long vowel sound. Conversely, most words that end with a double consonant get a short vowel sound.
So: when adding "es", "er", "est", or "ed" to the end of the word would appear to change the vowel sound, double the consonant.
quizes - ize is usually pronounced like "eyes", so change it to quizzes to preserve the short I sound
subed (short for "substituted") - ube is usually pronounced "oob" or "yoob", so change it to subbed
biger - ige is usually pronounced "eyej", so change to bigger
When there are two vowels before a consonant, you do not double the consonant; however, qu has its own sound, so the u is not "counted" as a vowel.
The absence of consonant doubling in "boxes" is regular
The letter X represents two consonant sounds (in this context, /ks/) and counts as two consonants in the context of the rules for pronouncing vowel letters as "long" or "short". Double X is very uncommon and not part of the typical English spelling system (see the answers to Why do we write "fixing" instead of "fixxing"?).
You can see the regular pattern -x → -xes in many other words like foxes, mixes, hexes, taxes, sexes, fixes, flexes, sixes, fluxes.
The presence of consonant doubling in "quizzes" might be considered regular (but words spelled like "quiz" are a bit unusual)
There are not very many examples of consonant doubling before -es, for several reasons.
The usual form of this suffix is -s. The form -es only occurs regularly after sibilant sounds: /tʃ/, /dʒ/, /s/, /z/, /ʃ/, /ʒ/. (It also occurs, but never with doubling, in plural forms ending in -ves that correspond to singular forms ending in -f.)
Consonant doubling is only regular after a stressed syllable, although there are some cases in English spelling of irregular doubling after an unstressed syllable (see "Focussed" or "focused"? Rules for doubling the last consonant when adding -ed).
Many of the sibilant sounds are either rare in word-final position after stressed short vowels, or have spellings that already doubled or that are incompatible with consonant doubling.
For final /tʃ/, /dʒ/, /s/, /z/, the "already-doubled" spellings -tch(es), -dge(s), -ss(es), -zz(es) are common. So we write witch(es), edge(s), kiss(es), mess(es), buzz(es), fuzz(es).
For final /ʃ/, the usual spelling <sh> is not doubled in any context. So we write fish(es), wish(es), ash(es), push(es), etc. When final /tʃ/ is not written double after a short vowel sound (such as attach, enrich) it is not doubled before -es either (attaches, enriches).
Words ending in /ʒ/ are extremely rare, words ending in a short stressed vowel followed by /ʒ/ are even rarer, and the most common spelling of word-final /ʒ/ is -ge, which has no corresponding doubled form. ("Corteges" may be an example of a word ending in /ɛʒɨz/).
So the issue of "to double or not to double before -es?" really only comes up with words ending in /s/ or /z/ preceded by a stressed "short vowel sound" and spelled with a single final S or a single final Z. There aren't that many words like this, so I don't know how much sense it makes to speak of a "general rule" for them.
Examples of Z being doubled before -es: quizzes, spazzes, whizzes, wizzes. But fezes and fezzes both seem to have non-negligible usage.
Examples of S being doubled before -es: buses, pluses, yeses, gases, Guses seem to be more common than busses, plusses, yesses, gasses, Gusses; but the latter forms exist. Biasses is listed in some dictionaries (e.g. AHD, Cambridge) but seems to be much less common than biases.
A few sources make the suggestion that the use of -ses vs. -sses might distinguish a noun form from a verb form; e.g. this web page says "A state of matter > GASES; (verb) to poison with gas > GASSES, GASSING, GASSED" and the Grammarist page on " Gases vs. gasses" says "In modern English, the plural of gas is usually gases, and gasses is the simple-present verb." The Google Ngram Viewer seems to provide a moderate amount of support for this distinction in that it shows a great deal of usage for gases as a noun, but no detectable usage for gases as a verb. The word gasses has a tiny but detectable amount of usage as a noun or as a verb.
If there really is a notable difference between the use of consonant doubling before -es as a noun suffix vs. as a verb suffix, the reason might be that consonant doubling is more frequent in the context of verb inflection (where there are many common examples of consonant doubling before the suffixes -ing and -ed) than in the context of noun pluralization.