Michel,
The On Exit takes an expression which will be evaluated. If you are poutting myvar = .F. in the On Exit then it acting exactly as it should. It evaluates the expression (Is MyVar equal to .F.). What you want ot do is create a PRG with MODIFY COMMAND, name it OnExit and in it put the line of code;
MyVar = .F.
Then in the On Exit you type OnExit() so it will call your prg. The prg will change the variable and return .T. (the default return value from a user defined function).