Doubts about End Gcode


I have two doubts, which as they are related I group in a post… both are related to the End GCode.

In the slicer I use (Super Slicer) I have end g-code configured as follows.
1- Finish printing
2- Change to relative coordinates
3- It separates in Z, 5 mm
4- Change to absolute coordinates
5- It moves to X0 Y400 (Secluded place in a corner)
6- Turn off the heaters, bed and nozzle
7- The engines are turned off.

Doubts about this end gcode.

1- Is there any way to tell Klipper, that at point 3, it separates 5 mm but up to a maximum of Z 400? It is unlikely, but in some very tall prints, for example 398 mm high, point 3 could not be fulfilled and the end gcode would be interrupted. Nope?

2- In point 5, before I moved to Y-400, but recently I put a 20x40mm heatskin fan on it, instead of the 10x40 one that he used. Well, this change means that when I move the print head to Y400, by 1 or 2 mm, it touches the structure of the printer, so I changed the printable area to 400x395x400 from 400x400x400mm.
Well, this small change, as I did NOT change it in the Slicer, means that when at point 6 of the end gcode it moves to x0 y400, it is interrupted, since it cannot be fulfilled, causing the gcode to not continue.
Is there any way (I think so, the issue is how), that the point where I send the print head is dependent on the measurements of the printer? That is to say that in point 5, instead of going to X0 y400, go to X(min) Y(Max), whatever it is… So if in the future I change the dimensions of the printer in the cfg again… I don’t have to update the in gcode, nor the gcodes that I already have sliced

Both topics could be solved via macros. See