Buffer close() calls, and fix some straggler tests.

Part of #229.