Fix internal close calls

Fix for #39, #40