How to close serial port when window is closed

I found the solution.

Credit : Found info here

Here is the code:

void exit() {
    println("Exiting program");
    myPort.stop();  // stoping serial port.
   //your Code above. 
   super.exit();
}
1 Like