properly closing serial connection