close input and output streams.  close service when close app