whirlpool washer spin problem

our whirlpool has a problem when the cycle is complete the clothes are still very wet. there is no water left in the washer but they are not dry enough to put in the dryer. I can manually restart the spin cycle so it spins out another couple of minutes then they can be put in the dryer. I dont believe its a balance problem. When I start a load the washer will start agitating imediately as it fills for the first time. When it works correctly the agitator will not start as the washer fills.

The washer will be working fine for weeks on end. then all of a sudden start doing this, and will continue to do it for a few days, then all of a sudden start working correctly again, and will continue to do so for a few weeks then suddenly start the same problem again for a few days before working correctly again.

Its like the timer gets out of sync somehow, then gets itself back into sync. Is it the timer or something else?