I don't think it really matters.
My logic says mags, then master, because it allows me to complete my shutdown checks (which may include checking engine instruments, writing down times/fuel remaining) while having a secured engine. And I can have lights on in the plane while doing that at night.