This only really applies to over the board games (since online chess servers prevent illegal moves).
In a standard time control game, under USCF rules, when the illegal move is noticed by one of the players, a few things happen. First, the illegal move must have been made within the last 10 moves. If not, then the current position stands, and play continues. Assuming that the move is recent, the position is restored to the position immediately before the illegal move.
Then, the player that made the illegal move now must make a legal move with the same piece (if one exists). If there are no legal moves, then the player is free to make any move. This is due to the touch move rule. Finally, if the offending player has pressed the clock, a two minute "bonus" is added to the opponent's clock to compensate them for any time lost and to penalize the offending player.
Here is the relevant passage from the USCF rulebook:
11A. Illegal move during last ten moves. If, during a game, it is found that one of either player's last ten moves was illegal, the position shall be reinstated to what it was before the illegal move. The game shall then continue by applying Rule 10, The Touched Piece, to the move replacing the illegal move. If the position cannot be reinstated, then the illegal move shall stand. Move counters on clocks that have them may by readjusted.
11D. Illegal move. If, a player completes an illegal move by pressing the clock, in addition to the usual obligation to make a legal move with the touched piece if possible, the standard penalty specified in rule 1C2a applies (i.e. two minutes added to the opponent's clock).
In blitz chess, the rules are different. According to the WBCA (World Blitz Chess Association) rules, a player who makes an illegal move loses the game instantly. This rule is frequently enforced in casual games too. The most common way that this occurs is that one player doesn't notice that they are in check and makes a move that doesn't get out of check. Then the checking player simply captures the king and claims a victory.
Because blitz is a much faster pace game, the illegal move must be noticed within two moves. If it is not, then the current position stands and play continues.
At no point is the game cancelled due to an illegal move. Pretty much once a game starts and both players make a move, a result of win, loss, or draw will be recorded.