The introduction to the Monster Manual says a creature
with the improved grab ability can take a -20 penalty on
grappling checks to avoid being treated as grappled and so
keep its Dexterity bonus to Armor Class and continue to
threaten the area around it, among other benefits. How
long does the -20 penalty last? And how long is the creature
not considered grappled?
   Any creature can opt to take -20 on a grapple check to avoid
the more unpleasant aspects of grappling (such as losing your
Dexterity bonus and being subject to sneak attacks from
rogues), not just creatures with the improved grab ability.
   Once you decide to take the -20 penalty, the penalty applies
to all grapple checks you make until your next turn. Should you
succeed at a grapple check and actually establish a hold on an
opponent despite the penalty, you are not considered grappled.
(If you fail to establish a hold, you wouldn't be grappling in
any case, unless someone grabbed and held you.) On your next
turn, you can stop taking the -20 penalty (which could help you
maintain your hold or pin your opponent), but if you do, you
are considered grappled until it's your turn again, at which
point you can either let go or start taking the penalty again.