This machine will not wash or rinse with a bad lid switch,therefore,we rule out the lid switch.
Unless you have water siphoning out the drain hose,the problem lies with an intermittent timer operation.
Could be a loose connection in the wire harness.
My thoughts are a weak timer motor or bad timer gears.