Short Answer:
Try EXIT_FORM(NO_VALIDATE);.
Long Answer:
It seems you may be handling the inserts yourself manually versus letting the form do it automatically upon committing. If you are using a database data block, the form will be prepared to save and/or insert any changes. If you go to leave, it will recognize that changes were made, but committing was not performed.
There are really a few ways to approach this, such as figuring out why the insert error is occurring and letting the form handle the updates. Since you already have working inserts and are confident that what needs to be saved is saved, then it may be best to simply bypass the error.
In the ON-EXIT trigger, or wherever you have the line of code that attempts to exit the form, I imagine you have a line calling EXIT_FORM;. Try adding the NO_VALIDATE option to that call EXIT_FORM(NO_VALIDATE);. This will ignore that check for changes and simply exit the screen. You can even use this in calls to EXECUTE_QUERY. I recommend using the built-in help tools to see the different types of options you have. One may come in handy in another scenario.
Keep in mind that this approach will not stop the insert error from occurring if the user is able to attempt to save the form by other means. We are only ignoring the check which prompts the message, which leads to the error if you say "YES". One way to keep the inserts and updates from occurring automatically, again without forcing you to abandon your already working code and use the built-in functionality, would be to add ON-INSERT and ON-UPDATE triggers to your block and simply enter NULL; so that they essentially do nothing.