In my case, an OPTIMIZE task was killed with mysql's kill command, but killing it did not stop the process. So sometimes even if you kill the task, it still stays.
> show processlist;
| Id | User | Host | db | Command | Time | State | Info | Progress |
+-------+-------------+-----------+-----------------------+---------+------+--------------------------+------------------------------------------------------------------------------------------------------+----------+
| 1 | system user | | NULL | Daemon | NULL | InnoDB purge coordinator | NULL | 0.000 |
| 2 | system user | | NULL | Daemon | NULL | InnoDB purge worker | NULL | 0.000 |
| 3 | system user | | NULL | Daemon | NULL | InnoDB purge worker | NULL | 0.000 |
| 4 | system user | | NULL | Daemon | NULL | InnoDB purge worker | NULL | 0.000 |
| 5 | system user | | NULL | Daemon | NULL | InnoDB shutdown handler | NULL | 0.000 |
| 142 | admin | localhost | tsa | Sleep | 20 | | NULL | 0.000 |
| 5114 | admin | localhost | something_wp | Killed | 5419 | Parallel repair | OPTIMIZE TABLE `wp_options`
Although it says Killed, it stayed in the process list..