Put the set interval in a variable and then use clear interval.
var myInterval = setInterval( function(){
$("#seconds").html(pad(++sec%60));
$("#minutes").html(pad(parseInt(sec/60,10)));
}, 1000);
function myStopFunction() {
clearInterval(myInterval);
}