Wish the one in my kitchen did that, it flew in through a partially open window and couldn't get back out again even after I opened the back door and 3 other windows fully, just kept flying into the glass. Stupid thing flew upstairs in the end so I trapped it in the spare bedroom.
God it’s so annoying, I’ve got a large window at the other end of the room to the patio doors and they fly in straight for the window and relentlessly head butt it over and over again, shitting all over the ledge in the meantime, despite the fact THE WINDOW IS FULLY OPEN!! Stupid creatures. Though, I have recently found a system that works, I approach, with a rolled up newspaper and announce ‘Get out or die’. It’s remarkably successful tbh.