Be more stringent about cleaning up resources.

Signed-off-by: Chris Lalancette <clalancette@gmail.com>