Same way he did in DOFP except that in the original timeline they fail to stop Mystique. Time travel make my head hurt, I mean if you prevent something happening in the past and it change the future how can you prevent it in the first place. Star Trek 4 is one of the few time travel story to work logically. Otherwise you need a parallel timeline "plot device" to make it work. Or you go into the time can't be changed route.
from reddit: the front page of the internet http://ift.tt/1o8aAPR