Infrared Sensor Adjustable - Program Stops

Hello everybody! I am writing a program that simply calculates the time between two successive triggers of the Infrared Sensor.

When I open the serial, it shows me the results of program's running. After a period of time (~30 sec), serial stops logging and program "stops".

I have to press the reset button on Arduino's board to re-run the program. What causes the issue? I can't find a solution on what's is going on. The program is simply enough.

Here is the code I use:

int IRPin = 7;
int a1, a2, jump = 0;

void setup(void) {
  Serial.begin(9600);
}
 
void loop(void) {
  if(jump==0){
    Serial.println("When ready, jump!");
    jump = 1;
  }
  if (digitalRead(IRPin)==1 && a1==0)
  {
    a1 = millis();
    Serial.println("On air...");
  }
  if (digitalRead(IRPin)==0 && a1>0)
  {
    a2 = millis() - a1;
    Serial.print("Total time: ");
    Serial.print(a2);
    Serial.println(" msec");
    a1 = a2 = jump = 0;
  }
}

Also, this is the sensor I use!