fixed crash during shutdown