You cannot just up and decide you no longer want to be in the military and then just leave. You leave when the military decides you can leave. Even at the end of your enlistment the military can force you to remain. Or once you are out the military can force you back in. It's commonly referred to as stop-loss.
Maybe you would like to try another analogy?
Modern American volunteer military service is a contractual agreement between the two parties. One agrees to serve a set period of time and is not required to remain in past that time, despite what your retention NCO and officer might want.
Also, people conveniently ignore the Declaration of Independence when making the argument that States must remain in the Union. That document makes it pretty clear that is not the case, else that little dust-up back in the 18th century would not have happened.