If you’re an independent contractor, most of your jobs will be work for hire. (You’ve been commissioned to help your client develop something new.) With work-for-hire agreements, your clients will end up owning all rights to the work they commissioned.
However, you must transfer your rights to the client, and your agreement will need to specify this.
Based on US copyright law, as soon as you put an idea down in a tangible form, you own the idea. If I write three words on a napkin, I own the copyright to those three words. With work-for-hire jobs in the US, you must assign the rights to someone else, even if you’re creating content for clients. Otherwise, the rights stay with you. So, make sure you have a clause in your agreement that assigns rights to the client, and make sure that the clause protects you.
Put this clause in your work-for-hire agreement:
“All rights will transfer upon final payment.”
Now, it will behoove your client to make sure you’re paid IN FULL. This means you retain all rights while you’re working on the project. The rights don’t automatically transfer at any other time—unscrupulous clients can’t abandon the project having partially paid you (or not at all) and own the rights. (And jobs fall apart for many reasons when there are great, honest clients involved.) This also means—if you still own the rights—that a client can’t do anything with the commissioned work without your permission.
When you create your milestones, the last milestone should be the final-payment milestone. Clearly state it as such.
If that final payment isn’t made, for whatever reason, you own a shiny, new intellectual property. And you can do whatever you want with it.