DF-1947. Replaced dynamic_cast with static_cast
DF-1893. Fix crash when closing tab