Ian Stannard took victory in the penultimate stage at the Tour of Britain as Julian Alaphilippe held his overall advantage.