jQuery function to show popup on window close
$(window).bind("beforeunload", function() { return confirm("Do you really want to close?"); });