The bill will end free movement and give the government full control of UK borders for the first time in four decades.