... # 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 #### ... # launch the window $pid = fork; unless( $pid ) { `MyGUI.exe`; exit 1; } sleep 10; # long enough for the GUI to launch # here is the kicker: kill 9, $pid; # now continue with my usual testing...