Closing the sample
When you press X to exit the sample, Stop is called. This stops the EtherCAT network and the KINGSTAR Subsystem. Then Destroy is called to close the link to the KINGSTAR Subsystem and terminate the Subsystem.
void CMFC_GUIDlg::OnClose()
{
::Stop(); //Stops the EtherCAT network and the KINGSTAR Subsystem.
::Destroy(); //Closes the link to the KINGSTAR Subsystem and terminates the Subsystem.
if (CanExit())
CDialogEx::OnClose();
}