US appeals court rejects Trump's request to end legal status for 400,000 migrants