Mechanisms of plasma disruption and runaway electron losses in tokamaks