At home, I turn it off.
In the theater, I do one of two things -- if its a pretty empty theater, and I'm with friends, AND it's pretty obvious that no one is enjoying the movie, then we start adding our own MST3K-style commentary. I've only done this twice (Fantastic Four 2, and one other that I can't quite remember). I have never once received an angry glare from a fellow audience member for this, so I think I've got good judgment as to when it's appropriate.
If I'm on my own, or some of the audience is enjoying the movie, I start to look at it from the perspective of a writer. I ask myself: why does this suck? What would I do differently to make the story less convoluted/idiotic/derivative/etc. I usually take a notepad along with me to movies for this exact reason, and I sometimes get some good writing ideas from it.
Of course, I sometimes get good ideas by doing a similar thing with good movies.