MATLAB: Warning message when closing app designer app

appdesignerclosedeleteMATLABwarning

When closing an App Designer app (even if it consists only of a close request function; see attached mlapp file), I always get a warning message similar to this one (I am working on a Mac):
appDeleteWarning
Warning: The file '/Users/__/Desktop/appDeleteWarning.mlapp' could not be cleared because it contains
MATLAB code that is currently executing.
> In appdesigner.internal.service.AppManagementService/unregister (line 148)
In matlab.apps.AppBase/delete (line 8)
In appDeleteWarning/UIFigureCloseRequest (line 12)
In appdesigner.internal.service.AppManagementService/tryCallback (line 283)
In matlab.apps.AppBase>@(source,event)tryCallback(appdesigner.internal.service.AppManagementService.instance(),app,callback,requiresEventData,event)
In matlab.ui.internal.controller.FigureController>@(o,e)this.Model.hgclose() (line 277)
In internal.Callback.execute (line 128)
In matlab.internal.webwindow/onCustomEvent (line 1104)
In matlab.internal.webwindow>@(source,data)obj.onCustomEvent(data.Type,data.Data) (line 262)
In asyncio.Channel/onCustomEvent (line 446)
In asyncio.Channel>@(source,data)obj.onCustomEvent(data.Type,data.Data) (line 378)
Is there anything that I should do differently when closing an app (e.g. any "cleanup" prior to calling "delete(app)")?

Best Answer

Restart MATLAB. If that does not resolve the issue, execute the following commands:

>> restoredefaultpath
>> rehash toolboxcache

If this works, execute:

>> savepath

*Note: *This will remove any custom paths you may have created. If desired, please see the following link for how to back them up:

https://www.mathworks.com/matlabcentral/answers/166871-how-will-running-the-restoredefaultpath-and-savepath-commands-affect-my-custom-paths-and-how-do-i-ba