Added code to query user if leaving a page.