You’re free to leave a cash game table any time you wish to do so. In poker tournaments, it’s not smart to leave the table unless there’s a break, as your stack will be eaten away by the blinds if you’re not playing.