You can also try:
Names Default to Here( 1 ); 
keepopen = 0; 
New Window( "Example", Show Menu( 0 ), Show Toolbars( 0 ), Suppress Autohide, 
  <<Modal, <<On Validate(!keepopen),
  Text Box( "Example: Keep Dialog Open Checkbox" ), 
  Text Box( "" ), 
  H List Box(
    keepcbox = Check Box( "Keep dialog open", keepopen = keepcbox << get( 1 ) ), 
    Button Box( "OK", 
      // Insert name of an expression to run as a script 
    ), 
    Button Box( "Cancel")
  )
);
<<On Validate(expression),  runs the expression when the OK button is hit.  If the expression returns 1 then it will close the window.  This has the benefit of allowing Cancel and X buttons to actually close the window, but prevents OK button from doing so.