      subroutine exit_swing

      include    'swing.cmn'
      include    '($ssdef)'

      character  logical_name*50, command*121, translated_name*120
      integer*4  translate_logical, lib$do_command, istat, len_string

      if ( proc_created ) then
         call process_command( 'stop/id=0', window3, 1 )
         call sys$dassgn( %val(inbox_channel) )
         call sys$dassgn( %val(outbox_channel) )
      end if

      if ( do_save .and. swing_file_exists )
     .      call record_structure( .false. )

      call smg$delete_pasteboard( board_id, 1 )
      call smg$change_pbd_characteristics( board_id, 80 )
      call reset_terminal( 'SYS$COMMAND', set_term_buf )
      print *,disk(1:len_disk)//
     .        node(node_num).spec(1:node(node_num).length)

         logical_name = 'SWING$EXIT_PROCEDURE'     !Check for user's exit proc
         istat = translate_logical( logical_name, translated_name )
         if ( istat .eq. ss$_normal ) then
            command = '@'//translated_name
            call str$trim( command, command, len_string )
            call LIB$DO_COMMAND( command(1:len_string) )
         end if

      stop ' '
      end
