When my cat was little, he did that too. I just kept saying "NO" loudly and putting him on the floor. It took a LOT of persistance but finally he stopped. I would stop sewing if he wouldn't listen and put the cover on the machine until he went away.
The spray bottle does work, I actually got some cat mouth wash because for awhile his breath was rank...he hates the stuff and just 1 spray in his direction and he runs far away and hides.