Every time you enter a new chunk, a random monster spawns, and the border closes around that chunk. The only way to get out is to defeat the monster.