Fixed a reference problem leading to client not getting terminated normally. thx mannol