The effect of confinement and defects on the thermal stability of skyrmions