Lots of bugs are attracted to lights. Also, some bugs can get into large places through small holes but can't get out. That's how minnow traps are designed.
Sometimes bugs just feel comfortable. Leaving is a big step. The world outside is filled out potential hazards for a bug. Some bugs can be perused to leave with the promise of free frozen yogurt.
I've noticed that bugs always get close to the door, but when they are about to leave, they get trapped again. Why is that?