When you want to exit the application, simulate the user clicking the close button.
GLFWwindow *window=...; PostMessageW(glfwGetWin32Window(window), WM_CLOSE, NULL, NULL);