Fixed segment fault when shutdown.