can be done as under, two options: In 2nd option, Excel is closed.
Sub closing()
ThisWorkbook.Activate
For Each Window In Application.Windows
If Not Window.Index = ActiveWindow.Index Then
Window.Close Savechanges:=True
End If
Next Window
ThisWorkbook.Close Savechanges:=True
End Sub
OR
Sub quitting()
For Each w In Application.Workbooks
w.Save
Next w
Application.Quit
End Sub