C**********************************************************************
C
	SUBROUTINE IFEXIT
C
C	SHUT DOWN THE DIFFRACTOMETER
C	MOVE TO A CONVIENIENT ANGLE AND WAIT UNTIL SAMPLE IS LOADED.
C
C	If there is an automatic sample changer this is the place to
C	control it.
C
      INCLUDE 'COMMON.FTN'
      INCLUDE '[RADIX]INTERFACE.COM'	
C Uses ITYP, IF1, IFSTAT, KICK & SETANG
C Calls IFMOVE.
C
C======================================================================
C
C  Wait for sample to be loaded.
100	WRITE(ITYP,104)
104	FORMAT(' Close shutter and remove sample.')
C
C  Don't shut down interface if it was never initialized.
	IF(IFSTAT.EQ.0) GOTO 9999
C
C  Move to a nice angle.
	CALL IFMOVE( SETANG, 0.0)
C
CCC  Wait until sample is unloaded, if necessary.
CC	WRITE(ITYP,114)
CC114	FORMAT(' Press return when done: ',$)
CC	READ(IRD,124,END=9999) JUNK
CC124	FORMAT(A1)
CCC
CC  Move to 90 degrees so the detector won't get bumped.
CC	CALL IFANGL( 90.0, ANGL)
CC	CALL IFMOVE( ANGL, 0.0)
C
C   close the unit to the interface.
C
	CALL SYS$DASSGN(%VAL(ICHAN))
	ICHAN=0
C
C  Interface status is not initialized  
	IF(IFSTAT.GT.0) IFSTAT = 0
C
9999	RETURN
	END
