Try this:
$(window).on('beforeunload', function() {
if($('fieldset.quote-step4').hasClass('show')) {
return;
}
return "Are you sure you want to leave the quote request page? This will reset the form.";
});
And it is not the best idea to use DOM1 Handlers when jQuery is already on your page.