Add guards when closing connections so that we can call the cb