Thanks! Apparently, I wasn't understanding the code fully.
Anyway, I have implemented both of your suggestions and both work. I will stick to the latter one as I find it to be more elegant.
I'm pasting the resulting end gcode in the hopes that it will be useful to somebody:
G1 E-2 F1800; retract G91; relative positioning G1 Z5 F1800 ; lift Z relative to current position G90; absolute positioning G1 X5 F6000; move to X min G1 Y5 F6000; move to Y min G1 Z150 F1800; move to Z max G10 R0 S0; turn extruder heater off M291 P"Do you want to cooldown the printer?" S3 G10 R45 S45; set extruder temp to 50C M106 S255; turn part-cooling fan on M116 S5; wait G10 R0 S0; turn extruder heater off M106 S0; turn part-cooling fan offThanks for your input!