Try
[marlinfw.org]
M84 ; disable motors
; BED COOLER
M42 P57 S255 ; start fan
G1 X0 Y200 F2000 ; move bed to front
M190 R30 ; wait until the bed reaches 30 degrees before continuing
M42 P57 S0 ; stop fan
M140 S0 ; turn off bed
;
M106 S0 ; turn off fan
[marlinfw.org]
M84 ; disable motors
; BED COOLER
M42 P57 S255 ; start fan
G1 X0 Y200 F2000 ; move bed to front
M190 R30 ; wait until the bed reaches 30 degrees before continuing
M42 P57 S0 ; stop fan
M140 S0 ; turn off bed
;
M106 S0 ; turn off fan