Stability and phase transitions of dynamical flow networks with finite capacities