WIth z probe homing use one f the preheat homing variants to set probing position to possible position.
You need also to activate pre raise (requires dev version)
#define ZHOME_PRE_RAISE 1
#define ZHOME_PRE_RAISE_DISTANCE 40Please note that printer does naturally not know z before homing so it will always go up 40mm. Means you should limit z to zmax-40 so this is always possible or be careful if you had a higher print to lower first before disabling printer.