You should always close the memo file before terminating the program to insure that the file buffer contents are written to the disk. There are two ways to close the file; the choice depends on how you opened it. If you opened the file in Basic, then you have to close it in Basic:
CLOSE #CHANNEL
where CHANNEL is still set to the same number as it was for the OPEN statement above.
If you opened the file with the MMO'OPN opcode, then you need to make a separate XCALL to close the file, using opcode MMO'CLS:
OPCODE = MMO'CLS
XCALL INMEMO,OPCODE,TEXT,CHANNEL,...
IF POS <> 0 CALL INMEMO'ERROR'RECOVERY
The only parameters of interest for this call are opcode, CHANNEL and POS (for error reporting); all others are ignored.