Improve buffer closing to avoid closing the window