Hice esto por si te funciona.
<html>
<body>
<button id="btn">
Test
</button>
<p id="cont">5</p>
</body>
<script>
let btn = document.getElementById("btn");
let cont = document.getElementById("cont");
btn.onclick = ()=>{
if(typeof(time)cont.innerHTML != "undefined")5;
let time = clearIntervalsetInterval(time();=>{
cont.innerHTML = 5;
if(cont.innerHTML == 0 || time>1){
time = setInterval(()=>{
cont.innerHTML--clearInterval(time);
if(cont.innerHTML == 0){
time = 0;
clearInterval(time);
return 0;
time = 0;}
}cont.innerHTML--;
}, 1000);
}
</script>
</html>