The UK will become the first country to leave the EU, ending its 47-year membership, and enter a transition period.