fix issue with connections not closing properly on define method. #14