A term that you should look up is "sakoku." That will tell you what you need to know. Bascially, Japan was so bothered by the influence of foreigners (mainly because of the impact of Christian missionaries) that they stopped letting foreigners in AND they made it a capital crime for a Japanese to leave Japan.
At first the Japanese seem to have been open to a limited amount of contact with the west, but eventually they became concerned and thus greatly curtailed such contact until the mid-19th century. The U. S. State Department sccinctly sums up the whole matter in one paragraph:
Contact With the West
The first recorded contact with the West occurred in about 1542, when a Portuguese ship, blown off its course to China, landed in Japan. During the next century, traders from Portugal, the Netherlands, England, and Spain arrived, as did Jesuit, Dominican, and Franciscan missionaries. During the early part of the 17th century, Japan's shogunate suspected that the traders and missionaries were actually forerunners of a military conquest by European powers. This caused the shogunate to place foreigners under progressively tighter restrictions. Ultimately, Japan forced all foreigners to leave and barred all relations with the outside world except for severely restricted commercial contacts with Dutch and Chinese merchants at Nagasaki. This isolation lasted for 200 years, until Commodore Matthew Perry of the U.S. Navy negotiated the opening of Japan to the West with the Convention of Kanagawa in 1854.