ref #1894 [fixed serious crash on app termination]