Fixed crash when closing program while connecting.