Fixed crash on delete_event on preferences window if thread is not defined