Workaround for socket closing bugs that can cause a hang

* clean up sockets before attempting to abort background threads
* hang can be caused by a race condition with socket file descriptors
(bug 19665) or sockets that are left open (such as in
UnixServerChannel or XplatUIX11)

Change-Id: I30299f7ae38d4039d2d60fddf3ff8c35658762ad