Need Help Stopping Countdown

I’ve built a countdown timer, but I can’t seem to condition the countdown to stop. Presently, the timer just keeps running, unless I click the “pause” btn.

Use case:

Users can input the timer’s value. On button click, the timer counts down from the value users input. When the timer reaches zero, the countdown should stop, and (later) it will do something.

Here’s my code (note the “CONDITION” comment):

function timerButtons() {
    $w("#startButton").onClick(function () {
        start();
    });
    $w("#pauseButton").onClick(function () {
        pauseTimer();
    });
}

///////////////////////////////////////////////////////

var x;

function start() {
    x = setInterval(timer, 10);
}

function pauseTimer() {
    clearInterval(x);
}

///////////////////////////////////////////////////////

var milisec = 99;
var sec = 10;
var min = 0;
 
var miliSeconds = 0;
var seconds = 0;
var minutes = 0;
 
function timer() {

    miliSeconds = checkTimerZeros(milisec);
    seconds = checkTimerZeros(sec);
    minutes = checkTimerZeros(min);
    
    /////////// CONDITION TO STOP TIMER at ZERO(s)
    
    if ((min === 0 ) && (sec === 0) && (milisec === 0)) {
        clearInterval(x);
        // Do something...
    
    /////////// END CONDITION
               
    } else {
        milisec = milisec - 1;
        if (milisec === -1) {
            milisec = 99;
            sec = sec - 1;
        }
        if (sec === 0) {
            min = min - 1;
            sec = 59;
        }
        $w("#timer").value = `${minutes}:${seconds}:${miliSeconds}`;
    }
}
 
function checkTimerZeros(i) {
    if (i < 10) {
        i = "0" + i;
    }
    return i;
}

Thanks so much, everyone.