add closeBuffer functionality