A Theory of Stability in Dynamic Matching Markets