You should follow the directions in the recipe, but as a general rule you should always allow the cake to cool for around 10 minutes before removing it from the cake tin. This allows it to firm up and reduces the chances of it breaking.