Bug 707255 - Open preferences when quitting causes assertion failure.

Wrong order of destruction functions were causing critical warnings on
g_signal_handlers_disconnect_by_func() calls.
Also g_object_ref/unref() the container because the tree handler might
hold the last ref to the container, once it's disconnected the container
could be gone.