In Path of Exile, click o to open the Options windown. Then click UI, and click Confine Mouse to Window option.
In this way, your mouse cannot move out of the game window unless you exit the game.
3.19.1 Patch Notes: The "Confine Mouse to Window" Option now confines your mouse to be within the maximum supported aspect ratio for those using larger aspect ratios (to prevent accidentally clicking on black bars).