Yes, its known as pool hopping and its generally discouraged by pools because it will affect the other miners and the pool owners.
Unfortunately, with the use of PPLNS and PPS systems in pools, these kind of attacks cannot work against the pools.
For the PPLNS system, the pool will reward the miners who mined the last n shares before the block. If you exit the pool early, you will not get anything.
For PPS system, the system pays you immediately, regardless of when it finds the block. This will also deter pool hopping.
Wow I did not know about such systems which works behind the stage. Pool hopping logically seems to be unprofitable as you said pool will not generate any rewards for you if we left early or before the block can be identified. But why PPS system would follow exact? Isn't both of them are aimed to mine from the same pool or are they regardless of that (PPS and PPLNS systems). Why one rewards immediately and one doesn't. I wanna know about them, any more guide on that please. Would be happy to know more about them.