To escape the illusion, whether it's from ancient lore or showcased in various movies and television shows, pain has always been one of the most straightforward and natural ways out.
If it weren't for the presence of the double vision of Divine Sense, Zachary would have never thought that the illusion he was currently in could simulate pain.
To many, illusions are quite similar to dreams, and it isn't clear when people started to confirm whether they were dreaming by slapping themselves hard in the face; if they didn't feel the pain, then it indicated they were still in a dream, and if they did feel pain, on the contrary, it proved they were in reality.
However, this time, the pain simulated in the illusion was so convincing that, had Zachary not confirmed through his Divine Sense that the Flying Needle hadn't actually pierced his leg, the intense pain shooting all the way to his head would have made him believe he had escaped the illusion.