If you use the shell class in async mode to run scripts over ssh on a server, you can get in a state where the shell object is dead. For example if you send three times the wrong password to ssh. The shell sits there and waits, ssh is running in the background doing nothing. If you call close on the shell class or let it go away (calls destructor), your application hangs.
The workaround is to detect this wrong password attempts (ssh asks three times) and put the shell object in a global array. Later in app.close you check if something is in the array and if yes, you do your cleanup manually (like closing main window) and call ExitMBS(0). This way you terminate your application without letting the REAL Studio framework destruct all objects.