When “keeping bees” you are ever only hosting them. If the conditions are not to the hive’s liking, they will find somewhere else to live. This is a significant problem in North America where honeybees are not native, as they will displace native species. But if you have a productive hive, they are happy and well treated.
My understanding is that the queen bee is generally restricted from leaving the hive by a physical gate. The workers won’t leave without her.