Fix closing freeze