Walgreen Boots Alliance said it will close the stores over the next three years after losses widened.