Globalization has made the world far more interconnected. Technology and economic factors that make it easier to transport people, things, and ideas. The UK is trying to go "back to the future," where they can exert a level of control over outside influences affecting their country. Problem is, that level of control hasn't existed since the early 1900's (mid-1900's at the latest). They are swimming against the tide rather than letting it push them forward.
Political borders are phasing out because the political institutions that created and enforce them are losing their monopoly on social identity. People still have a national identity to an extent, but that is slowly yielding to social and cultural identities. We are seeing this in the US, even despite the high levels of nationalism here. More and more people are identifying as Conservative, LGBT, Christian, Feminist, Ethnic, etc first and American second. This process is still in its early phases in the US, but it will continue barring a dramatic event that re-establishes our national identity as dominant. Even then, that will only be a temporary thing.
New "soft borders" are being drawn alongside cultural and social fissures rather than political boundaries. The EU was (and still is) a fascinating experiment in how to harmonize national boundaries with more fluid social/cultural ones. Member states have national governments, but also accept authority outside of their nationality. The economic aspect also important. Before, countries had to exercise control over resources in order to reap the benefits. The EU allows member countries benefit from resources within the greater union rather than just their own territory.
By breaking away, the UK is forfeited these advantages and to preserve their national identity. This is simply not realistic, and untenable in my opinion. Even if they manage to police their borders, foreign culture, norms, and ideas will still flow into the UK via the internet, economics, and other cultural exports. They will still find their country's domestic norms and values shaped by the outside world.
The EU recognized that globalization is at a point of no return. They try to adjust so their countries remain stable under the cultural and social pressures of outside norms and ideas flowing in. The UK's decision shows that there are too many people who think they can return to a former time in history they are comfortable with (not unlike the US). They either want to hide from globalization, or they reject it outright. For centuries, the UK influenced the outside world. Now, it is being influenced and that scares people. The EU carefully waded into the shallow end of the lake by having national and super-national union leadership, open borders, and special trade agreements. The UK was fine with this so long as it didn't actually have to get wet. The water rose up to its ankles, so it wanted out. Sooner or later it will get wet though. It can either wade in like the EU, or get thrown in by globalization.
Sorry for the long post, but globalization is changing a lot about the world. It's important to understand the wide range of factors it influences. If you want to see globalization at work, just look at how weather conditions in Australia, Pakistan, and Russia led to the Arab Spring.