Fix buffer closing

0cbf5fc4 uncovered an old bug
Thanks for noticing, @torhve