When does client decide to stop/cancel proof of work algorithm? I have been reading about bitcoin and blockchain in the last few days, but I have something I don't clearly understand.

The "proof of work" may take a long time for a simple node to guess, but if we combine all nodes, they guess it in 10 minutes. 
Now lets say another node guessed it faster than me, how do I know when I should stop my proof of work algorithm?
Is there any point on keep trying to guess it?
When do you start trying to guess the next proof of work?

Hope the question is clear.
Now lets say another node guessed it faster than me, how do I know when I should stop my proof of work algorithm?
When do you start trying to guess the next proof of work?

Whenever a node successfully solves a proof-of-work it immediately broadcasts it to the whole network. So whenever you hear a block that you are trying to solve you should stop and start mining a fresh block on top of the newly received block