Exodus 21:3-4

21:3 If he came in by himself he will go out by himself; if he had a wife when he came in, then his wife will go out with him. 21:4 If his master gave him a wife, and she bore sons or daughters, the wife and the children will belong to her master, and he will go out by himself.