code: def buffer_close(self, buf, redraw=True):
          
  
          # call pre_buffer_close hook
          prehook = settings.get_hook('pre_buffer_close')
          if prehook is not None:
              prehook(ui=self, dbm=self.dbman, buf=buf)
  
          buffers = self.buffers
          success = False
          if buf not in buffers:
              logging.error('tried to close unknown buffer: %s. \n\ni have:%s',
                            buf, self.buffers)
          elif self.current_buffer == buf:
              logging.info('closing current buffer %s', buf)
              index = buffers.index(buf)
              buffers.remove(buf)
              offset = settings.get('bufferclose_focus_offset')
              nextbuffer = buffers[(index + offset) % len(buffers)]
              self.buffer_focus(nextbuffer, redraw)
              buf.cleanup()
              success = True
          else:
              buffers.remove(buf)
              buf.cleanup()
              success = True
  
          # call post_buffer_closed hook
          posthook = settings.get_hook('post_buffer_closed')
          if posthook is not None:
              posthook(ui=self, dbm=self.dbman, buf=buf, success=success)
docs: closes given :class:`~alot.buffers.Buffer`.
  
          This it removes it from the bufferlist and calls its cleanup() method.