If the Pdb command step is used after the last line of the script, Pdb will set the trace_dispath function as the trace function of the caller's frame. Consequently, the trace_dispath function will be called at line 48 after the script execution has finished.
https://github.com/simonsobs/nextline/blob/a0ed6aae1b7cc38f4648a7118408091d989e767f/nextline/main.py#L45-L49
The trace_dispath function is set in Bdb.set_trace()
https://github.com/python/cpython/blob/v3.9.5/Lib/bdb.py#L298-L308