Added feature to warn users that unsaved changes have been made before cancelling, with the optional ability to disable this or override the default message.