wait for buffer to be drained before closing
Merge pull request #351 from nkzawa/patch-6

wait for buffer to be drained before closing