I expect everyone knows how to do this, but I’ve just discovered it . So, just in case I’m not the only one…
To remove empty bars from the end of a piece, just select the last bar which contains notes, then shift-B and enter something like -100 and all the empty bars will disappear.