Not necessarily, what would happen in this case is that once you are compelled your contract to work on the code is terminated. Nothing illegal about such a contract.
You effectively are your employer (via a contract for services rather than employment per se). So by them giving you the notice they are also informing your employer.
You then get to fire yourself; it is definitely a burn it to the ground strategy, but this type of strategy has happened before and no doubt will happen again even if infrequently.