It's as simple as deciding to license your software under a particular license. This is not technically contract law, but copyright law. As the owner/licenser of your intellectual property (the source and binaries) you may license its distribution anyway you see fit. Providing a clear disclaimer as to the recipients rights under the license is all that is necessary. Without a license, whether closed or open, no one has a right to distribute your copyrighted work. The purpose of all licenses is to grant some of your rights to other parties.
See here for more information. Or for perhaps too much information, check out O'Reilly's Understanding Open Source and Free Software Licensing.
~ William Riley-Land