Tasks are completed and remain running

Problem:
The job_invocation module of Ansible collection theforeman.foreman is executed, the task finishes correctly and sometimes stays in the running state and does not switch to succeeded.

Foreman and Proxy versions:
Foreman: 3.12.1
Foreman-proxy: 3.12.1
foreman-tasks: 9.2.3
foreman_ansible: 14.2.1
foreman_puppet: 7.0.0
foreman_remote_execution: 13.2.5
foreman_webhooks: 3.2.3
katello: 4.14.1

Foreman and Proxy plugin versions:
dynflow: 0.9.3
shellhooks: 0.9.3
pulpcore: 3.3.0
script: 0.11.4
ansible: 3.5.6
tftp: 3.12.1
dhcp: 3.12.1
puppetca: 3.12.1
puppet: 3.12.1
logs: 3.12.1

Distribution and version:
Red Hat Enterprise Linux release 8.10 (Ootpa)

Other relevant data:
I have checked other similar topics and for example in the file /etc/foreman-proxy/settings.yml the variable :foreman_url has a value.

Task info:
Label: Actions::RemoteExecution::RunHostsJob
Raw input:

{
  "job_invocation": {
    "id": 21,
    "name": "Ansible Playbook",
    "description": "Description of the task invoked"
  },
  "job_features": [],
  "job_category": "Ansible Playbook",
  "job_invocation_id": 21,
  "proxy_batch_size": 100,
  "trigger_run_step_id": 5,
  "current_request_id": "0ec91c18-35d5-4a3c-ab97-bd1c9883c3b2",
  "current_timezone": "UTC",
  "current_organization_id": null,
  "current_location_id": null,
  "current_user_id": 4,
  "dynflow": {}
}

Raw output:

{
  "host_count": 1,
  "remote_triggered_count": 0,
  "planned_count": 1,
  "cancelled_count": 0,
  "total_count": 1,
  "failed_count": 0,
  "pending_count": 1,
  "success_count": 0
}

Sub task info:
Label: Actions::RemoteExecution::RunHostJob
Raw input:

{
  "host": {
    "id": 23,
    "name": "example.host.com"
  },
  "host_display_name": "example.host.com",
  "job_category": "Ansible Playbook",
  "description": "Description of the task invoked",
  "job_invocation_id": 21,
  "job_features": [],
  "delegated_action_id": 2,
  "with_event_logging": true,
  "current_request_id": "0ec91c18-35d5-4a3c-ab97-bd1c9883c3b2",
  "current_timezone": "UTC",
  "current_user_id": 4,
  "current_organization_id": null,
  "current_location_id": null
}

Raw output:

{}