In a private company, the shares are automatically cancelled.
A public company has the option to cancel the shares or to hold them 'in treasury'. Shares held in treasury can later be sold, transferred in connection with an employee share scheme (e.g. when an employee exercises a share option) or cancelled.