Correcting this kind of mistake depends on the pattern. For some things you may want to undo the rows and correct the extra sts. I think that for a dishcloth, you could knit 2 together 4 times across the row, maybe once at the beginning of the row, two times somewhere towards the middle and once near the end of the row. Then you should be back to 40sts. But how and whether to correct the extra sts is up to you.
Increases and decreases could become an added feature of the pattern!