MATLAB Runtime Server    

Using the CloseRequestFcn to Exit the Application

As a minimal measure, you should configure the CloseRequestFcn property of the main GUI figure window to exit the application. This allows the user to exit the application by clicking the GUI window's Close box.

For example, the following command creates a GUI window whose Close box executes a function called shutdown when clicked.

This shut-down function, which you write, can perform final operations (such as saving the user's work and settings) and then explicitly execute the quit command. Note that the shut-down function should close the GUI figure window before executing the quit command. This prevents possible recursion between the quit function and CloseRequestFcn.


  Providing a Way to Exit the Application Using a Uicontrol or Uimenu to Exit the Application