Is it possible to stop receiving BPM after a while?

Then measure for 10 seconds and stop:

bool measuring = false;
unsigned long startMeasuring;

void loop() {
  if (measuring == false) {

    // Start measuring.
    measuring = true;
    startMeasuring = millis();
  }

  if (millis() - startMeasuring < 10000) {
    measureBPM();
  }
  else {
    processBPM();

    // To do another measurement, trigger the first if block again:
    measuring = false;

  }
}