Masterwork bug when exiting without removing item. Reverts back to 0

Masterworked a ring, got upgrade to dmg per dark shorud shadow. upgraded 2 more levels. All i had mats for. Press O to exit without removing item from the masterworking tab. Then item lost all masterwork levels, I lost the material and the money. Item back to lvl 0.