Might not be the same for you & your LO, but my baby was doing the same at around the same age. Feeding fine until the end, then fighting & getting cross and bobbing on & off. Would be fine when I switch sides, then start again with the fussing after a while. If I took her away she'd still be rooting & aeem upset so I assumed she was still hungry & assumed I either wasn't making enough milk so she was getting cross when it ran out or that she was lazy and wouldn't keep suckig to get the next let down.
Anyway I was wrong & it turned out I had over supply & fast flow so in actual fact she was finished but getting annoyed because whenever she sucked milk came out yet she just wanted comfort. Hence bobbing on & off. She was getting cross because I thought she hadn't had enough so kept trying to make her latch on. Ooops! Anyway because various BF problems present the same or similar symptoms it's trial and error ruling things out over time. I had to see a breastfeeding support worker who watched a feed & explained it to me. I'd recommend seeing someone or giving one of the helplines a call. good luck x