If I understand you well,
// M140 - Set bed target temp as end g-code does not work because it does not control your heated bed.
So the question is :
- can I connect the ulticontroller to my heated bed
- can I make a connection in series between the two "switches".
To cool down quickly, you could use
// M106 - Fan on
// G4 - Dwell S or P
// M107 - Fan of
I am just guessing.