G4 command being ignored while printing via SD


I have the following gcode in the "After print job completes" section of Octoprint:

   G4 P300000; Wait 5 minutes to let the Hot end cool
   OCTO3; Shutoff LED
   G4 P3000; Wait 3 seconds
   OCTO1; Shutdown via script

If I send a job to the Ender through Cura, no issues and the commands execute correctly but if I print via the SD card, then the G4 commands are ignored (the other custom commands execute correctly).

Printer: Ender 3
Version: Version 1.3.10
Marlin version: 1.1.9
Hardware: Raspberry Pi 3 B+
Plugins: GCODE system commands


Any thoughts here please?


Any logs here please? Especially octoprint.log, serial.log.