Shutdown after the last thread ended