First off, even though the Americans and the Japanese didn't go to war, yet, the perceived threat provided an impetus for Japan to start thinking about itself differently. It also resulted in the Japanese being convinced that if they wanted to maintain their independence, they would have to reconstitute their country as a modern nation-state. This looks a lot like what was happening in Egypt or even in Germany, with external pressures leading to calls for greater national consolidation. So the Tokugawa didn't give up without a fight, but the civil war between the stronger daimyo and the Bokufu eventually led to the end of the shogunate. And in 1868, the rebels got the newly enthroned Emperor Meiji to abolish the Bokufu and proclaim a restoration of the imperial throne. Now the emperor didn't have much real power, but he became a symbolic figure, a representative of a mythical past around whom modernizers could build a sense of national pride. And in place of Bokufu, Japan created one of the most modern nation-states in the world.