New Zealand closed its borders to all foreigners from midnight on Thursday, as it stepped up efforts to contain the spread of the coronavirus in the country.