como parar o timer com outra função javascript

Então eu tenho esse código

function timer()
{
     setTimeout(function(){alert("Out of time")}, 3000); //Alerts "Out of time" after 3000 milliseconds
}
function resetTime()
{
     timer(); //this is not right, i thought it would override the first function but it just adds another timer as well which is not what I want
}
function stopTime()
{
     //What could go here to stop the first function from fully executing before it hits 3000 milliseconds and displays the alert message?
}

a função timer () é iniciada à medida que a página é carregada, mas se eu tiver um botão para stopTime () e clicar nela, como interrompo a execução da primeira função e paro de atingir a marca de 3000 milissegundos e alertando "Out of time "?

questionAnswers(3)

yourAnswerToTheQuestion