yeah, ok, you can't do it there.
To understand why, may be helpful.
The form runs through many "stages" - which are broadly categorized into 3 phases;
a) initialization before the form displays
b) generating the form
c) handling the "Ok" button of the form.
Now you're killing the session smack-bang in the middle of the 3 phases. Meaning that anything set up during phase (a) is lost. And this is a bad thing. (It prevent's (c) from working).
So, a better place for the two lines of code, is at the top of the InitForm routine, which runs towards the beginning of phase 1.