Run segment deactivation code only if segment is active.