When you disconnect from the last server, HeidiSQL asks if you want to save the script, if there is one. If you select cancel, then the window stays visible without an open connection. Almost any action you try to perform now will crash the application.
I recommend disconnecting after the "Save changes" question. This way, "cancel" also makes sense.