What do I do to get the 8th gym leader back to their gym in X & Y

Can someone please tell me how to get the 8th gym leader of Pokemon X & Y back to their gym? I’m up to battling them and I don’t know what to do.