When I use Gdx.app.exit() the game window closes but the resources don't appear to be released and the app is still running.

For instance, to exit on when the escape key is pressed:

public boolean keyDown(int keycode) {


    if (Gdx.input.isKeyPressed(Keys.ESCAPE))

The window closes, the dispose() method is called but Eclipse still reports that the app is open (because the terminate button is still available): Eclipse reports that the app is still running

If the app had exited properly, the path to the JVM would have <terminated> in front of it, and the red terminate button would be greyed out.

Also when I use hide() and then dispose():

public void hide() {


public void dispose() {
    System.out.println("----- END OF OUTPUT -----");


The same thing happens. You have to terminate the app with the button provided by Eclipse, or in the release version use the kill command (or task manager).

So my question is, how can I properly exit the app so all resources are gracefully unloaded, the window hides and the process exits in LibGDX?


2 Answers 2


I found the solution!

In my DesktopLauncher class, I had set config.forceExit to false instead of true, which caused the app to exit incorrectly (keep the running in the background.)

You need to set config.forceExit to true

And there are no AL lib cleanup errors or native-related libraries having issues.

  • \$\begingroup\$ Thanks, it still works on 2021! That line of code must be placed after LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); Also I checked in terminal that there isn't anymore the process active. \$\endgroup\$ Commented Feb 3, 2021 at 21:09

A simple System.exit(0); should do the trick. Depending on your project setup, Gdx.app.exit(); could be terminating the LibGDX app, and not the entire program, where an added system exit will kill the runtime.

  • \$\begingroup\$ Thanks, I've tried System.exit(0) and while it does work it gives me an AL lib: alc_cleanup: 1 device not closed error, which I've read is harmless but I'd prefer to exit the app without any errors. I'll use this as a temporary fix in the mean time. Thanks ;) \$\endgroup\$
    – Matt Y
    Commented Oct 1, 2015 at 3:33
  • \$\begingroup\$ It's now giving my other errors like: pure virtual method called [new line] terminate called without an active exception so I think I'll avoid it. \$\endgroup\$
    – Matt Y
    Commented Oct 1, 2015 at 3:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .