Hysteresis and free boundary problems