ensure when moving between tabs we don't crash and recover if possible

fixes #2234