Fix intermittent crash on model close.

This fixes cmb!163.
Status Job ID Name Coverage
  External
passed ghostflow-branch-check-master

failed ghostflow-branch-check-release

passed ghostflow-commit-check

passed ghostflow-commit-check