Will not complete cycle

Sometime the dishwasher cycles through and completes cycle. More often than not, it starts and then hangs-up and the Rinse Only lights flashes constantly and there is water left in washer. Sometime when you press CANCEL-Drain, it will not do anything and the water stays. Open the door for awhile, push CANCEL-Drain, then will drain. Then it may start cycle again and then after a few seconds, jump back into Rinse Only light flashing. Never seems to finish cycle.