Over the past years it became evident that the quality factor of a superconducting cavity is not only determined by its surface preparation procedure, but is also influenced by the way the cavity is cooled down. Moreover, different data sets exists, some of them indicate that a slow cool-down through the critical temperature is favourable while other data states the exact opposite. Even so there where speculations and some models about the role of thermo-currents and flux-pinning, the difference in behaviour remained a mystery. In this paper we will for the first time present a consistent theoretical model which we confirmed by data that describes the role of thermo-currents, driven by temperature gradients and material transitions. We will clearly show how they impact the quality factor of a cavity, discuss our findings, relate it to findings at other labs and develop mitigation strategies which especially addresses the issue of achieving high quality factors of so-called nitrogen doped cavities in horizontal test.