I battled against the Zygarde inside of Terminus Cave and I used my Malamar against it first in order to slowly bring its HP down. It took a while for that to happen and I actually messed up the first two times that I tried and Zygarde fainted, but I had saved beforehand so I kept attempting to weaken the Zygarde until its HP was at the red zone and then I started tossing Dusk Balls at it. I switched to Ultra Balls once my stock of Dusk Balls started running out and I caught Zygarde after 10 minutes of trying. After catching Zygarde, I used an Escape Rope and I returned to Route 18. I went back to Couriway Town next and I healed my team at the local Pokemon Center. I then swapped my team on the PC and saved.