<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def on_touch_up(self, touch):
 """Stop dragging if needed."""

        if not self.dragging:
            return
        touch.ungrab(self)
        self.dragging = False