Handle world closing correctly.