Unable to unload within this context (Error 365)

In some situations you are not allowed to unload a form or a control on a form. This error has the following causes and solutions: