If you have many empty bars at the end, try my idea in this thread.
If you select where you’re working and hit P twice, that sets the playhead there, so then if you inadvertently hit Space it won’t jump away. Also there’s a hidden command Play > Move Playhead to > Selection that does the same thing, which can be assigned a shortcut.
Also I just discovered default shortcuts involving Space for Play From Start Of Flow and Play From Last Start Position that perhaps one could hit accidentally.