Fix OS X code. - Close the connection properly on destruction. - Work around what seems like an Apple bug.