Close buffer the better way