Why did the samurai era end?

The urbanization of Japan and the banning of the wearing of swords led to the end of the era of the Samurai. Japan was no longer isolated following the opening of trade which also contributed to the ending of the Samurai era.