Fixes ctrl+c bug if socket-thread is still alive