You can use the “ss” or “lsof” command to identify the process that is using the socket/port in a TIME_WAIT state and then use the “kill” command to force close it.
Example using ss:
$ ss -tna | grep <port_number>
The output will show the process using the socket/port.
kill -9 <process_id>
Example using lsof:
$ lsof -i:<port_number>
The output will show the process using the socket/port.
kill -9 <process_id>