emit end when disconnecting with an empty pool

I added a test that fails (timeout) without the patch.