Whirlpool Trash Compactor

Trash compactor won’t turn of at the end of the cycle (top). I have to press the off switch to turn it off. When I press the on switch, the cycle will start over. The ram will go down and up again and not stop. I have replaced the "top limit directional switch" but that did not help. What is the most probable cause of the problem?

Thanks
Ted