Pulse counting program randomly stops working

I have a relatively simple sketch that counts pulses for a duration of one second and turns a couple of outputs on & off based from the pulse count. For the input signal, I’m using a square wave generator (0 to 1khz) for testing purposes.
Everything is working as it should but……
My issue is that the program randomly freezes. I notice this because my LCD display stops changing values as I vary my input pulse count up and down, also my outputs stop working. I can keep varying the frequency up and down sometimes for 3 to 4 minutes with no problem, then for whatever reason it stops working while I’m testing it.
I have been working on solving this for some time but I am stumped at this point.
One thing I noticed is that if I remove all the conditional “if” statements and just use the sketch to display the frequency count on the lcd it doesn’t freeze up.
Perhaps someone here may have some insight as to what the cause may be.
Thanks.

/* Motorcylce radio automatic volume control.
    Overview.....
    This sketch will count pulses from a speedometer reed switch for one second and turn two relays on and off based off of the pulse count (speed).
    One relay simulates pushing the volume up switch and the other relay simulates pushing the volume down switch on the handlebars.
    The volume will be turned up at 30mph and again at 50mph, and then down when under these speeds.
    The LCD is being used for calibration/testing purposes*/


#include <LiquidCrystal.h>

volatile int pulsecount = 0;//incoming pulses from speedometer
unsigned long lastmillis = 0;
const int interruptPin = 2;
const int volume1 = 500; //pulse count turn up volume at 30mph, 500 pulses = 30mph
const int volume2 = 800; //pulse count turn up volume again at 50mph, 800 pulses = 50mph
int memvolume1 = 0;  //set memory to remeber volume1 has exceeded 30mph
int memvolume2 = 0;  //set memory to remember volume2 has exceeded 50mph
LiquidCrystal lcd(12, 11, 7, 6, 5, 4);

void setup() {
  lcd.begin(16, 2);//set column, rows
  pinMode(interruptPin, INPUT_PULLUP);
  pinMode(13, OUTPUT);//pin for volume up relay
  pinMode(9, OUTPUT); //pin for volume down relay
  attachInterrupt(0, pulse_wheel, FALLING);//interrupt zero (0) is on pin two(2).
}

void loop() {

  if (millis() - lastmillis == 1000) { /*Uptade every one second, this will be equal to reading frecuency (Hz).*/

    detachInterrupt(0);    //Disable interrupt 

    lcd.clear();
    lcd.setCursor(0, 1);
    lcd.print(pulsecount);//display pulse count on LCD screen
    delay(500);

    if ((pulsecount > volume1) && (memvolume1 == 0)) { //if over 30mph for the first time turn on the up volume relay for 1 second
      digitalWrite(13, HIGH);   // turn on volume up relay
      delay(1000);              // wait for a second
      digitalWrite(13, LOW);    // turn off volume up relay
      memvolume1 = 1; //remember you went over 30mph to turn the volume up
    }

    if ((pulsecount < volume1) && (memvolume1 == 1)) { //if under 30mph, turn on the down volume relay for 1 second
      digitalWrite(9, HIGH);   // turn on volume down relay
      delay(1000);              // wait for a second
      digitalWrite(9, LOW);    // turn off volume down relay
      memvolume1 = 0; //reset memory volume for over 30mph
    }

    if ((pulsecount > volume2) && (memvolume2 == 0)) { //if over 50mph for the first time turn on the up volume relay for 1 second
      digitalWrite(13, HIGH);   // turn on volume up relay
      delay(1000);              // wait for a second
      digitalWrite(13, LOW);    // turn off volume up relay
      memvolume2 = 1; //remember you went over 50mph to turn the volume up
    }

  if ((pulsecount < volume2) && (memvolume2 == 1)) { //if under 50mph, turn on the down volume relay for 1 second
    digitalWrite(9, HIGH);   // turn on volume down relay
    delay(1000);              // wait for a second
    digitalWrite(9, LOW);    // turn off volume down relay
    memvolume2 = 0; //reset memory volume for over 50mph
    }


  pulsecount = 0; // Restart the pulse counter
  lastmillis = millis(); // Uptade lastmillis

  attachInterrupt(0, pulse_wheel, FALLING); //enable interrupt
}
}

void pulse_wheel() { /* this code will be executed every time the interrupt 0 (pin2) gets low.*/
  pulsecount++;
}

What happens if millis() - lastmillis is not exactly 1000 but maybe 1001? This Level of precision may be causing you to hang up and is not necessary. Try millis()-lastmillis >= 1000.

That's it. I ran it for over 30 minutes with no issues. Thank you for taking the time to help me.