Application.Quit command not closing the entire Excel Application

I have following code under a button. When clicked it just closes the current Excel sheet but not the entire Excel application.

Application.DisplayAlerts = False
ThisWorkbook.Save
Application.DisplayAlerts = True
Application.Quit

Note: I don't have any other sheets open.

The following window still appears.

enter image description here


Solution 1:

I had this issue and I resolved it by putting in the Workbook_BeforeClose():

ThisWorkbook.saved = true

Solution 2:

remove the Application.DisplayAlerts = True from the routine.

from the help for Application.Quit Method:

If unsaved workbooks are open when you use this method, Microsoft Excel displays a dialog box asking whether you want to save the changes. You can prevent this by saving all workbooks before using the Quit method or by setting the DisplayAlerts property to False. When this property is False, Microsoft Excel doesn’t display the dialog box when you quit with unsaved workbooks; it quits without saving them.

This will avoid any (possibly hidden) prompts from stopping excel from closing completely