Try this. It checks if the user has clicked on any of the inputs, if they have then it’ll fire the warning when they go to close the tab. If the user doesn’t click on any of the inputs it’ll let them leave without bothering them. I just did a rough test on this, it may not be perfect.
<script>
var userStartedForm;
jQuery(document).on('focus', '.gform_wrapper input', function(){
userStartedForm = true;
});
jQuery(window).on('beforeunload', function(){
if(userStartedForm){ return ''; }
});
</script>