before to stop your program , don't forget to clean the memory properly , for instance :
rem main program
disable escapekey()
do
....
if escapekey() then exit
loop
for i = 1 to 6553(
if object exist(i) then delete object i
if matrix exist(i) then delete matrix i
if image exist(i) then delete image i
if sprite exist(i) then delete sprite i
if mesh exist(i) then delete mesh i
next i
for i = 1 to 1014
if sound exist(i) then delete sound i
next i
for i = 1 to 32
if animation exist(i) then delete animation i
if file open(i) then close file i
if music exist(i) then delete music i
next i
for i = 1 to 31
if bitmap exist(i) then delete bitmap i
next i
for i = 1 to 7
if LIGHT EXIST(i) then delete light i
next i
EMPTY CHECKLIST
DELETE STATIC OBJECTS
sync off
backdrop off
cls
flush video memory
This code is effcient when there are no crash during the excution of the programm.