print #handle, "!trapclose branchLabel" ;

This command tells Just BASIC to continue execution of the program at branchLabel if the user double clicks on the system menu box or pulls down the system menu and selects "close."