Hello Michael,
When opening a session, Rocket TE Desktop stores its settings in the registry, kind of like locking this session, say S1, until this session is closed normally and these settings will be cleaned from the registry at that point. Your script uses WMI object to kill/terminate the session process (bzmd.exe), so bzmd.exe will be exited abnormally therefore it has no chance to do clean work. In addition, similarly, if terminate the script host process (bzsh.exe) as above, it would cause the script can't exit as expected if some script is running. In a word, it's not recommend to terminate any RTE process in this way since it would easily cause data corruption or mess as you saw.
Hope this makes sense.
Thanks,
Zhi