Improve buffer closing

Now it should work with NERDTree flawlessly.