Usage of this statement does not cleanly close scope. Local variables will not have their destructors called automatically, because FreeBASIC does not do stack unwinding. Only the destructors of global variables will be called in this case.
For this reason, it is discouraged to use End simply to mark the end of a program; the program will come to an end automatically, and in a cleaner fashion, when the last line of module-level code has executed.
Note: STOP is not implemented properly yet; currently it is the same as SYSTEM.
For each library I write, I write an exit function that could be called a destructor. Each would clean up mutexes, CONDs, special allocations, terminate threads, etc. I use Linux, only. Frequently, the console state (local or remote) doesn't get cleanly cleared. I have a function set that clears this, also. I even have a few debug routines that give me good data on fail situations.
I have one general destructor that tests if a library is present (at compile time) and will call each appropriate exit function at program close.
END does what it says: it does not call any destructors.
STOP from anywhere will call my general destructor and then all my exit code is executed. Program traps can correctly dump info and close everything down nicely without me having to unwind everything. I can kill a program from anywhere and everything is happy.
Should anyone choose to work on this function (STOP) ---
PLEASE DON'T CHANGE THIS 'FEATURE'
This 'incomplete' function helps SO MUCH as it is.
I just wanted to record somewhere that it works this way for me.