Cannot disable active tab in web right hand panel, switch away first (rebased onto develop)



This is the same as gh-1619 but rebased onto develop.

----

To reproduce bug on OmeroWeb:

* Select image in the left tree
* Click preview tab in right hand panel
* Click the root of the left tree
* Click preview tab in right hand panel -> 404

Fix: switch away from active tab before disabling it