refactored actor system shutdown code