Brickmaker to close factories after £52m loss