This should have been specified in the contract (lessons learned...). In the best case for you, you would have specified that non-performance of contract terms by the client is grounds for cancellation, maybe a three-strikes rule or something. You would also have specified "intellectual property transfers on satisfaction of contract"; even in a cancellation, if both parties have lived up to those terms (meaning you've been paid what you are owed according to the contract thus far and have delivered accordingly), the contract is "satisfied".
That then makes it clear that what you have developed now belongs to your client. That is, of course, assuming that other than the client being the source of insurmountable delays, the customer was in good standing with regards to payment for services rendered. If the client is withholding payment, you own the code until the matter is resolved to either mutual satisfaction or the court's.
By the way, if the contract does not stipulate what portion of the payment you are entitled to and what you are not based on the work performed, then if you drafted this contract, be prepared to fork over every penny they gave you, and similarly, if they drafted it, you should be refunding nothing. As was correctly stated in a Big Bang Theory episode a few seasons back, ambiguity in a contract benefits the party that did not draft it, to the extent the law allows (the contract doesn't have to specify the obvious, such as illegalities of law, but if you are neither required nor prohibited by law or contract to take a certain action, you may do as you choose regarding said action, so if the contract doesn't stipulate settlement of partial completion, the money and the code will go to whomever didn't write this sieve of a contract).