[Ide] Fix some issues in the document notebook

Make sure a valid tab is selected if the current tab is closed.

This fixes bug 23120 - On switching back to one editor column
exception 'System.NullReferenceException:' appears

Also fixes bug 22278 - Closing tabs with Apple+W leads to lost focus/blank editor.