INAL but even if you did not get paid does not automatically means the result of work for hire belongs to you. If you are a contractor this is a smart thing to explicitly stipulate in the contract.
Nice timing, in that I just wrote about this exact topic a few days ago at: https://nickjanetakis.com/blog/protecting-your-code-and-ip-w...