free the surface before checking for errors