Fixed race-condition in case node shutting down