Fixed bug when terminating client fails