I'm grateful to @SiddharthRout for providing the solution:
As he says, saving the Workbook_BeforeClose
procedure in a workbook causes the newly added procedure to be executed when the workbook is closed, ending the current workflow if it has an END
statement.
This is what @SiddharthRout comments Problems closing a workbook after using .VBComponents