When a superconducting radiofrequency cavity is cooled through its critical temperature, ambient magnetic flux can become "frozen in" to the superconductor, resulting in degradation of the quality factor. This is especially problematic in applications where quality factor is a cost driver, such as in the CW linac for LCLS-II. Previously, it had been unknown how to prevent flux from being trapped during cooldown in bulk niobium cavities, but recent R&D studies showed near-full flux expulsion can be achieved through high temperature heat treatment and cooling cavities through the superconducting transition with a spatial thermal gradient over the surface. In this paper, we describe the first accelerator implementation of these procedures, in cryomodules that are currently being produced for LCLS-II. We compare the performance of cavities under different conditions of heat treatment and thermal gradient during cooldown, showing a substantial improvement in performance when both are applied, enabling cryomodules to reach and, in many cases, exceed a Q0 of ~3×10 10 .