In igneous rocks, quartz forms as magma cools. Like water turning into ice, silicon dioxide will crystallize as it cools. Slow cooling generally allows the crystals to grow larger. Then, when the temperature or pressure drops, the solution becomes saturated, so quartz crystals form.