Russia's X5 Retail Group has finalised a deal to sell its stores in Ukraine, marking its exit from the country.