Close socket when worker is terminated
Simplify statements on worker