My 2015 MBP has a magnetic sensor on the left side. My TI2 pen has magnets to hold the cap on. One day I placed my pen next to my laptop and the screen shut off because the magnet caused it to think the lid was closed.
My coworker has a 2018 MBP that does not respond to the pen. However, when he disconnects from his external monitors with his laptop screen up, his computer will completely lockup, as if it thinks the lid is closed. Opening it and closing it has no effect, and the trackpad goes completely dead (no haptic - just like my laptop when the pen is placed beside it).
My theory: I know other people with the same issue when disconnecting from hubs/docks. I guarantee more than a few have gone to the Genius Bar about this issue. This sensor is so the machine knows if the display is actually closed or not so it does not lock up for those and similarly-affected users.