Cancel unload in onPageWillUnload

Is there any way to cancel the unload in the onPageWillUnload event? I want to ask the user something like “You are going to exit this page. Are you sure?” And if the user answers no, I need to cancel de unload and do nothing.

Thank you