Thermal stability of single and multi-walled carbon nanotubes