how to make a receiver shut off after receiving?

I'm working on an electrical engineering project for school in which I'm modifying the invisible fence system for pets so that it shocks the animal when it leaves the yard, but not if it tries to go back into the yard after running out. It works on a transmitter/receiver link that shocks whenever the receiver on the dog's collar gets close enough to the antenna loop around the yard. My thought is to make it so that the receiver shuts off after receiving a signal. Is there any way to do this through code? I have zero knowledge of that except for what I've gleaned through working on this project, but that's not nearly enough. Here is the receiver code from this walkthrough. The transmitter code and wiring diagrams are there, if you'd like.

int incomingByte = 0;
void setup(){
  Serial.begin(4800);
}
void loop(){
  if (Serial.available() > 0) {
    incomingByte = Serial.read();
    Serial.println(incomingByte, DEC);
  }
  incomingByte = 0;
}

The only way I can think of for this to be implemented would be to have a second "fence" a little farther out of the yard that toggles the receiver. So the first loop would send a signal to shock and the second loop would transmit a different signal. Thus when the collar sees the shock signal first and then the second signal within a short time it would toggle the collar off but if it sees the second signal first and then the shock signal, eg. the dog is going back into the yard, then it doesn't shock the dog until the collar stops receiving the shock signal, at which time it arms the collar. Does that make sense? Otherwise how would you figure out that the dog has left the yard and not just gotten close to the fence and walked back into the yard? Just my two cents, best of luck!

I wonder could you use a collar that includes an Arduino device with GPS?

If the dog is at or above a certain range from a central point and the range is increasing he gets a shock. Whereas if the range is decreasing he doesn't get a shock.

No need for any physical perimeter fence.

...R

My thought is to make it so that the receiver shuts off after receiving a signal.

Wrong thought. You only need supply the shock when the receiver goes from not receiving anything to receiving something. In other words the edge not the level. That way any repeat shock will only occur when the dog has gone out of range and then back in range again.