close sockets in error conditions in main()