Fix closeConnectionTask bug
Fix compiling with g++ on Mac OS X