US stocks have closed higher as investors cheered news that the Strait of Hormuz would be reopened to commercial vessels.