fixed null pointer exception that could occur while shutting down