It's entirely legal. The amendment of 65 says nothing about the presidents ability to close borders due to national security concerns. This is the hyper liberal west coast judicial circuit making a play based on political agenda. They've done this before and they will continue to do it. Need to be removed from bench.
Even if that were the case, we have a court system that deals with the extreme judges and their rulings should they be disputable. If the ruling is questionable, appeal it to a higher court. If that's questionable, appeal it to yet another higher court. If those higher courts don't have any issues with it, you're SOL.
The court wouldn't be cleared out because it ruled unfavorably, the court should be cleared because it continues to interject its personal political beliefs into what is supposed to be a sterile unfeeling to the letter inactment of the law.
Actually that's exactly what judges should do. They're elected or appointed based on their interpretations of the law and their constituency being in favor of their reading and understanding of it. This happens from both sides, and it's why the supreme court is such a big deal. This works with the system of appeals to balance out anything too extreme, but it's the intention of how the system is set up.
The court system isn't some arbitrary floating body of starfishs that you disagree with, judges are people elected or appointed on faith from their constituency. While they're not supposed to inject their own politics into rulings, two judges can interpret things in very different ways, which is why any legal document is so specific.