Dialog for unsaved changes

Pulled the dialog code into its own method so it could be reused.