Note that undo only works once. So if you draw 3 lines and press ctrl+z, it will only undo the 3rd line and you'll have 2. Any further undos just reset it to back after you drew the second line. Any time you click or paste a stamp, that will set an undo point.
If you wanted to save your work, either use a stamp or hold ctrl and click on save to make a local save. Or save it online normally.