You can cancel the operation when creating lines or polygons.
If you have not finished drawing a line or polygon and would like to cancel the operation, press the Esc key. Existing segments will be deleted.
You can also right-click.
The line or polygon is not created.