We present a technique for increasing the internal quality factor of kinetic inductance detectors ( KIDs ) by nulling ambient magnetic fields with a properly applied magnetic field . The KIDs used in this study are made from thin-film aluminum , they are mounted inside a light-tight package made from bulk aluminum , and they are operated near 150 mK . Since the thin-film aluminum has a slightly elevated critical temperature ( T _ { \mathrm { c } } = \SI { 1.4 } { K } ) , it therefore transitions before the package ( T _ { \mathrm { c } } = \SI { 1.2 } { K } ) , which also serves as a magnetic shield . On cooldown , ambient magnetic fields as small as approximately \SI 30 \micro T can produce vortices in the thin-film aluminum as it transitions because the bulk aluminum package has not yet transitioned and therefore is not yet shielding . These vortices become trapped inside the aluminum package below \SI 1.2K and ultimately produce low internal quality factors in the thin-film superconducting resonators . We show that by controlling the strength of the magnetic field present when the thin film transitions , we can control the internal quality factor of the resonators . We also compare the noise performance with and without vortices present , and find no evidence for excess noise beyond the increase in amplifier noise , which is expected with increasing loss .