# Calling exit() using FX2D renderer doesn't stop program

**URL:** https://discourse.processing.org/t/calling-exit-using-fx2d-renderer-doesnt-stop-program/6414
**Category:** Processing
**Created:** [December 8, 2018, 4:08am UTC](https://discourse.processing.org/t/calling-exit-using-fx2d-renderer-doesnt-stop-program/6414 "2018-12-08T04:08:13Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Sarah](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sarah/32/1675_2.png) [@Sarah](https://discourse.processing.org/u/Sarah)
#### Post date: [December 8, 2018, 4:08am UTC](https://discourse.processing.org/t/calling-exit-using-fx2d-renderer-doesnt-stop-program/6414/1 "2018-12-08T04:08:13Z")

</div>

Hi,

I’ve noticed that when I call `exit();` in a program using the `FX2D` renderer, an error appears in the console: _Not on FX application thread; currentThread = JavaFX Application Thread_. This error usually appears when the program is not correctly shut down.

The Java app also stays open, while the sketch window is closed, and the only way it seems to be able to close the thread is to within the IDE stop it.

Is there a way to get around this, so it’s possible to exit the program, and can anyone else replicate this error?

Here’s what creates the error for me:

```auto
void setup() {
  size(100,100,FX2D);
  exit();
}

```

Thanks!

---

<div class="post-metadata">

### Author: ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)
#### Post date: [December 8, 2018, 3:30pm UTC](https://discourse.processing.org/t/calling-exit-using-fx2d-renderer-doesnt-stop-program/6414/2 "2018-12-08T15:30:47Z")

</div>

Hi,

Does the same happen with

```auto
void setup() {
  size(100, 100, FX2D);
}
void draw() {
}
void keyPressed() {
  exit();
}

```

? I can’t test because FX2D doesn’t work at all for me.

---

<div class="post-metadata">

### Author: ![Sarah](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sarah/32/1675_2.png) [@Sarah](https://discourse.processing.org/u/Sarah)
#### Post date: [December 8, 2018, 11:56pm UTC](https://discourse.processing.org/t/calling-exit-using-fx2d-renderer-doesnt-stop-program/6414/3 "2018-12-08T23:56:58Z")

</div>

Yes, calling `exit();` anywhere causes the error.

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [December 9, 2018, 1:18am UTC](https://discourse.processing.org/t/calling-exit-using-fx2d-renderer-doesnt-stop-program/6414/4 "2018-12-09T01:18:15Z")

</div>

> [@hamoid](#):
>
> void setup() { size(100, 100, FX2D); } void draw() { } void keyPressed() { exit(); }

using processing IDE 3.4

- win 7 32bit  
works fine
- raspberry pi Raspbian  
can not start:

```auto
java.lang.RuntimeException: You need to use "Import Library" to add processing.javafx.PGraphicsFX2D to your sketch.
	at processing.core.PApplet.makeGraphics(PApplet.java:2280)
	at processing.core.PApplet.createPrimaryGraphics(PApplet.java:2317)
	at processing.core.PApplet.initSurface(PApplet.java:10872)
	at processing.core.PApplet.runSketch(PApplet.java:10811)
	at processing.core.PApplet.main(PApplet.java:10511)

```

no idea what import i need?  
testing also P2D P3D on raspberry  
show me a black background window,  
the “key” exit works,  
but i get following red console info:

```auto
EGLDisplayUtil.EGLDisplays: Shutdown (open: 1)
EGLDisplayUtil: Open EGL Display Connections: 1
EGLDisplayUtil: Open[0]: 0x1: EGLDisplayRef[0x1: refCnt 2]

```

and for openprocessing

 ![snap-033](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/d351cfba72080a1321649de4cc01dd4bb8d59ba6.png)  
ERROR  
FX2D is not defined

---

<div class="post-metadata">

### Author: ![Sarah](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sarah/32/1675_2.png) [@Sarah](https://discourse.processing.org/u/Sarah)
#### Post date: [December 9, 2018, 1:29am UTC](https://discourse.processing.org/t/calling-exit-using-fx2d-renderer-doesnt-stop-program/6414/5 "2018-12-09T01:29:43Z")

</div>

You don’t need any libraries for the error to appear. Is an error thrown if you run this code?

```auto
void setup() {
  size(100,100,FX2D);
  exit();
}

```

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [December 9, 2018, 1:31am UTC](https://discourse.processing.org/t/calling-exit-using-fx2d-renderer-doesnt-stop-program/6414/6 "2018-12-09T01:31:03Z")

</div>

> Is an error thrown if you run this code?

NOT on windows 7 / processing IDE 3.4  
YES on Raspberry ( see above )

possibly you tell us your working environment?

---

<div class="post-metadata">

### Author: ![Sarah](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sarah/32/1675_2.png) [@Sarah](https://discourse.processing.org/u/Sarah)
#### Post date: [December 9, 2018, 2:37am UTC](https://discourse.processing.org/t/calling-exit-using-fx2d-renderer-doesnt-stop-program/6414/7 "2018-12-09T02:37:45Z")

</div>

> [@kll](#):
>
> possibly you tell us your working environment?

I’m using a MacBook air on High Sierra.

Can any other Mac users see the error?

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [December 12, 2018, 10:14pm UTC](https://discourse.processing.org/t/calling-exit-using-fx2d-renderer-doesnt-stop-program/6414/8 "2018-12-12T22:14:39Z")

</div>

> [@Sarah](#):
>
> Can any other Mac users see the error?

With

```auto
void setup() {
  size(100,100,FX2D);
  exit();
}

```

…I see the error

> Not on FX application thread; currentThread = JavaFX Application Thread

on macOS Sierra 10.12.6, MacBook Pro 13" 2016.

@Sarah, have you considered reporting this to [Issues · processing/processing · GitHub](https://github.com/processing/processing/issues/)

---

<div class="post-metadata">

### Author: ![Sarah](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sarah/32/1675_2.png) [@Sarah](https://discourse.processing.org/u/Sarah)
#### Post date: [December 12, 2018, 10:26pm UTC](https://discourse.processing.org/t/calling-exit-using-fx2d-renderer-doesnt-stop-program/6414/9 "2018-12-12T22:26:30Z")

</div>

Thanks for testing it out! I was waiting to report it because it seemed like no other users got it, but it seems that it’s a Mac related error.

I’ve opened an issue now:

> <https://github.com/processing/processing/issues/5722>
