code: public void closeAfterFlushingPendingWrites(Channel channel, Event event)
  	{
  		if (channel.isConnected())
  		{
  			channel.write(event).addListener(ChannelFutureListener.CLOSE);
  		}
  		else
  		{
  			System.err.println("Unable to write the Event :" + event
  					+ " to socket as channel is ot connected");
  		}
  	}
docs: This method will write an event to the channel and then add a close
  listener which will close it after the write has completed.
  
  @param channel
  @param event