Currently TiDB doesn't close a connection automatically, however if the client was down or something goes wrong, some connections are turned to be idle forever, which should be closed.
MySQL use the variable wait_timeout to define the number of seconds the server waits for activity on a non-interactive connection before closing it. We can follow this behavior as well.
For more detail, see: https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_wait_timeout
When the client is down or something goes wrong, some connections will not turned to be idle forever, unless tcp-keep-alive = false
I've tested it manually when tcp-keep-alive = true

Anyway, MySQL variable wait_timeout could be supported in TiDB.
For MySQL compatibility, there are actually two settings: wait_timeout and interactive_timeout.
Interactive applies to command line clients etc. Anything that sets the interactive 'bit' in the client protocol.
I will try to do this.
Support for wait_timeout has been added, so I am going to close this issue now. Support for interactive_timeout can be tracked in https://github.com/pingcap/tidb/issues/8487
Most helpful comment
I will try to do this.