API tests: fix file handle leak in SBT, thread exhaustion in Travis

I believe I finally have a handle on the multiple problems, and have fixed or worked around them here. What a pain.
Instead of sleeping, could you get all active threads in a loop, and wait until the netty ones have shut down? That way it will work whether it's less than or more than 1 second.