code: function(evt) {
          var layer = evt.layer;
          if (layer instanceof OpenLayers.Layer.Grid) {
              this.clearTileQueue({object: layer});
              if (layer.events) {
                  layer.events.un({
                      addtile: this.addTile,
                      retile: this.clearTileQueue,
                      scope: this
                  });
              }
              if (layer.grid) {
                  var i, j, tile;
                  for (i=layer.grid.length-1; i>=0; --i) {
                      for (j=layer.grid[i].length-1; j>=0; --j) {
                          tile = layer.grid[i][j];
                          this.unloadTile({object: tile});
                      }
                  }
              }
          }
      }
docs: Method: removeLayer
  Handles the map's preremovelayer event
  
  Parameters:
  evt - {Object} The listener argument