Discord's X button is implemented inside the webview and simply hides the window (to be revealed later by clicking the tray icon). It does not send WM_CLOSE or WM_DESTROY.
Alt+F4 is what actually closes the window, and in Discord's case, the entire rest of the app too.
Alt+F4 is what actually closes the window, and in Discord's case, the entire rest of the app too.