Better buffer closing management