What happens to BW when Cap America returns the soul stone to red skull guy?
Good question.
So here is how I would sketch it out.
Avengers time travel to whatever year (2014?) to get the Soul Stone. Widow dies and is sucked inside Soul Stone.
Soul Stone returned to the Endgame 'present' (5 years after Infinity War). Gets used here for Endgame events.
Cap returns Soul Stone back to Vormir in 2014.
Thanos in that timeline arrives during IW with Gamora and obtains the Soul Stone, trapping Gamora in there with BW
Thanos snaps in IW.
Thanos destroys the stones in beginning of End Game, presumably killing Gamora and BW. Unless it frees them.
The big time travel problem is Thanos from 2014 time traveled to the future and died here. So even if Steve returned the stones back to the past, there would be no Thanos left in that timeline to be Thanos and do the initial snap.
So for events to work with just what was shown on screen... we have to assume that when Tony snapped his fingers, he didn't just dust Thanos and his minions out of existence. He also had to return or recreate them in 2014 with no memory of a time traveling Nebula, of themselves time traveling to the future, etc. Basically oblivious of the rest of the Endgame events so they live out Infinity War as it happened.
And in typing that, I just created the theory of where Gamora went. Like Thanos and his minions, she was dusted and returned to 2014 so there would be a Gamora there to play out the events in IW. Quill and company wouldn't know where she went, she'd have just disappeared during the fight unless they saw her dust.
In which case Thanos destroying the Soul Stone could have freed both Gamora and BW.
(ETA: This doesn't address the change to the timeline with Loki, of course)
(ETA2: Edited version
here but read the above first)