Fixed the problem of not clean shutdown