Exit visual mode when cutting text in the editor

Fixes a crash when cutting text at the end of a file. Also ensures the cursor goes to the right spot after cutting.