Fix Gtk3 crash when running inside of IPython

As reported in #2624, the Gtk3 backends and IPython are not playing well together, and either no window is displayed, or Python exceptions or even segfaults are thrown.

This, along with https://github.com/ipython/ipython/pull/4640 seem to make everyone happy.