I've received a few angry emails from users that the code posted in this thread doesn't allow them to use the "back" button after they come to my site. So, I tested it myself and found that it is indeed very hard to go back to the image search after coming to the site as the code keeps breaking the frame and bringing you back to the site. This is obviously very annoying for the user and diminishes the user experience.
The following code however breaks the frame AND allows the user to hit the back button normally. I've tested it and it works like a charm
if (top.location != self.location)