... # launch the window $pid = fork; unless( $pid ) { `MyGUI.exe`; exit 1; } # much code to manipulate the GUI, etc here.. # now close the GUI.. &PressAButton( $gui_handle, "&Close" ); # should be done here