Magnetic fields implicated in the mysterious midlife crisis of stars