Ask for saving the patch when the user closes an edited patch

We can ask the user to save the edited patch before closing it to avoid any unintentional data loss.