I had this problem years ago and thought it was GW2's fault. It took me a while to realize that I had a short in my USB mouse cable. So when the power to the cable was cut when the wire was wiggled just right, it was as if I had unplugged the mouse and then plugged it back in, which was enough to bring me back out of GW2 to the desktop. I'm guessing a USB keyboard could do the same thing.