The Supreme Court handed President Trump a temporary win, permitting the administration to prematurely end a humanitarian program that had granted two-year legal status to half a million people.