Closing the python shell immediately quits gnucash. As mentioned in a code comment (init.py): # Hm. Gtk.main_quit will kill gnucash without closing the file # properly. That's kinda bad. That behavoir should change. Either do a regular shutdown or don't quit gnucash at all.
Yeah, calling gtk_main_quit kills the event loop. gnc_main_window_quit is the right function to quit GnuCash, but it's not exposed to the python bindings. Is there a use-case for the python console being able to shut down GnuCash? Shouldn't it just exit the console and leave it for the user to quit GnuCash the usual way?
It would make sense to just shut the console. There is no possibility to reopen it from running gnucash but in that case gnucash has to be restarted. That' no problem. If the shell would be more useful than it is now it may make sense to have it openable on demand. From a perspective of gui logic killing a subwindow should not kill the main program. I'll change it so closing the shell does not affect the main process.
https://github.com/Gnucash/gnucash/pull/491