closing sockets/streams with escape character