Magnetic stress as a driving force of structural distortions: the case of CrN