Check out example codes for "programatically close a jframe". It will help you in understanding the concepts better.

Code Example 1

// Sending a Event with the Window
// to be closed this way, will initiate
// the **closing** behaviour.
frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));

Learn ReactJs, React Native from akashmittal.com