You're asking the wrong questions!
If your worms are trying to escape the bin, they are deciding that their survival is more likely if they leave the bin. The bin is a hostile environment for them.
Before you force them to stay in the bin, you need to fix whatever is causing the bin to be a hostile environment to them and make it so they have every incentive in the world to stay in their bin.
Whats wrong with forcing worms to stay in their bin?
Every living organism has developed an overpowering instinct of survival. Either to survive as an individual, or as a species.
Worms are no different. They have not evolved to randomly decide to risk death without an enticing reward.
When your worms are leaving your bin (with the exception of the first few days when you first introduce them to your bin) because they feel it is better to risk their lives - leaving their moist bin, leaving behind all potential food - than to stay in your bin.
Your worms are thinking - I might die of dehydration, exposure to light, predators, large things stepping on me, or starvation, but its better than staying in this bin.
All of us are familiar with worms that come up from the ground after the rain. They do that for survival - they don’t want to drown in their burrows. They feel as though the odds of them surviving by staying in their burrow are worse than their odds if they leave it.
Your worms are saying the same thing.
The problem isn't the worms - its the bin. You are essentially forcing them to stay in their burrow while it fills up with water, as it were. Do not mandate a quarantine in a burning building.
Listen to your worms.
They’re informing you that your bin is not adequate for their needs, and they want to risk their lives to find somewhere better. No one knows the wants and needs of an earthworm better than an earthworm.
We must fix the bin.
How do I know if its a problem?
Now, sometimes one or two worms will leave your bin every once in a while. Like every few weeks or a month or so. I would chalk that up as anomalies. I know I just said that worms aren't dumb, but every species has some individual members who aren't up to par on the species average intelligence level. Or maybe they just were born with the need to explore, who knows.
But when it is a consistent occasion - several worms huddling together at the top or corner of your bin (assuming its not a mass feeding session), worms dying, or any number of worms leaving/trying to leave the bin consistently - they are telling you that your bin needs to be fixed.
The more consistently, and the more worms trying to leave/leaving, the more serious the problem.
What if I just added my worms to the bin?
When you first get worms through the mail (or however you get them) and introduce them to a new bin, they might try to roam just because they miss their old bin.
Or something like that, I don’t know. I haven’t personally experienced that, but it is a relatively common experience I have seen others come across.
Just be aware that if you get new worms and they’re trying to leave the bin, it could be because it's just a new environment to them. But you need to really pay attention to see if it could be anything else. Because if it is something else, you need to get it fixed asap.
Usually when worms come through the mail they are really dehydrated, so they have a huge incentive to stay in your bin. So you really shouldn’t be seeing a ton leaving. Especially if it is truly just because its a new environment, I wouldn’t expect to see many trying to leave.
Again, just pay attention and follow the general rule - the more worms trying to leave, and the more consistently, the more serious the problem.
How to fix it
There are several reasons your worms might be trying to leave. All of the issues and the fixes can be found (or will be found) elsewhere on the Vermicomposting Guides here. Typically it will involve some of the following:
Too wet
Too much food - which makes it too acidic
Not enough airflow
Poor quality bedding
Each of these ties back to the bin being anaerobic. You might find some guidance here: How to start worm bin
Most of these issues can be solved by adding additional QUALITY bedding. The bedding should create a safe space for the worms to live. It should help airflow for the worms to breathe, dry bedding will help soak up excess moisture if your bin is too wet, and bedding should be pH neutral and help balance out any pH imbalances.
My top two recommendations for bedding if you are having worms escaping would be shredded cardboard and coco coir. Both of these are great for airflow, soaking up excess moisture, and worms love it.