I had exactly the same problem about three months ago.... we had a smeg dishwasher, but it was doing exactly the same as yours. Everything worked only it kept emptying itself, which in turn rendered it useless.
In our case I did eventually find the fault, but it was too late as I had already started to break it up to sell on eBay for spares.
On a dishwasher you have a sump/base plate..... Floating in the sump you have a switch which is called the anti flood switch. It is basically a micro switch operated by polystyrene floats that rise when any small amount of water leaks from within the dishwasher and ends up in the sump. The switch operates the empty motor, and at the same time ends the rinse cycle.
So start by checking the sump for any sign of a leak, it only takes a up full of water to stop the cycle. The good news is your switch is working, otherwise your kitchen would be flooded.
When I broke my machine up I eventually found a tiny trace of scale which was the tell tale sign of a leak. It was totaly impossible to locate when the machine was running, but once I was removing the the components it was spotted....
The remedy would have been to tighten the screws that secure the sump from inside the washer . The ones which surround the filter plate. Or even replacing the sump gasket would propably have done it.
I collected over £100 for the parts on eBay.
When I