Update examples: clean resource when close connection.