If there is no custody order or pending custody case, then it is hard to prevent a parent taking a child out of state. This is because both parents have equal rights to the child. If there is an imminent threat to the child or they are taking the child out to evade jurisdiction, then you can try to get an ex parte order granting you custody until a judge can determine custody.
If there is a pending custody action or a custody order and they try to take the child out of the state, you can contact that state’s local law enforcement to get them to enforce the order and help you return the child.
In North Carolina, there is a law that makes it a crime if a person takes the child out of state with the intent to violate a court order.