Frame has a cross button on top right corner but it won’t be functional until you write the code for it. Code below makes the cross button operational.
frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we){
System.exit(0);
}