Businesses could prevent that by requiring employees to agree to a separate, permanent contract not to release any code as part of the conditions for being hired.
Right. And you can already refuse to accept a job if all the code you produce isn't open sourced. Good luck with that on most companies, though.