Fixed an error when a script is closed with no open 3D views.