Metro Group has ended months of speculation over its Extra business in Germany with an agreement to sell the business to local rival Rewe.