Minor bugfixes when quitting.