Fix resource leak #12

Fix Issue #12

Please merge this patch.