if you want to close form from code then put for example button in this form and then write in clicked function this line of code :

 

 

void clicked()

{

element.close();

    super();

}