Fix killing of the PrimaryLoop on shutdown.