Correctly handle mousemove events when switching between canvases or leaving the document.

Closes #250.