corrected version and made shutdown signal check optional