This has been happening to me for a while, and I just now tested it out to figure out what was the problem.
I found out that with a dual monitor setup (the only time this issue could occur) if you are panning with the right mouse button and the cursor is at the edge of the screen (the side next to the adjacent screen), then release the right mouse button and continue to move the mouse, the cursor will continue past the boundary of the game screen and put the cursor outside of the game.
This is an issue when you click (left mouse) because it acts like an alt tab and pulls you out of the game.
Please look into this, it is getting me killed in PvP