Fix crash on application termination.