Dangling search tasks which are even few days old

Elastic Search version: 8

We are passing timeout to search query and query is timing out properly if it cross that time. But I see a active task still running in /_tasks output.
few tasks are like days old and eating up resources.
some times i need to manually cancel the task and if doesn;t work restart the node.
How do we force the task to get cleaned up automatically as as it times out? There is no point running that further.