OS X session termination fixes

Note this builds on top of pull request #225 and includes the patch from that request.

No idea why, but session initialization and termination is behaving differently on OSX WRT empty bulk transfers.  This fix has been tested on OS X Yosemite and Fedora 20.