Close the TCP connection, after communicating with the client
optimzing memory usage for actual frame
adapted some comments