minor bugfix to avoid possible crashes when the instance is being destroyed

(because exiting)