How to quit the app when the main window is closed

My macOS app was rejected because "closing the main window does not quit the app."

I have implemented the

func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
    return true

method in my app delegate and it seems to close the app, so I'm not sure why it was rejected.

What can I do to resolve this issue?