You could add a check to your forever loop that would look for X and Y position being in a certain range and if they both were you could get it to stop, E-stop or whatever you wanted. You would need to know the start and end of the two zones for each axis.
Might be more practical to just really watch things closely for the first part. I used to do alot of 4th axis stuff at my last job, its not too bad after a while. One good piece of advice i can give you is to take the 4th axis off when doing non 4th axis work. Even if you think you have enough room lol.