Added script shutdown code.