Fixed startup and shutdown issue