The question suggests two 21.5" iMacs set up to use Target Disk Mode, with Mid 2014 one acting as a display. The "Mid 2018" one (probably a 2017 or Retina 4K 2017 model) would be old enough to use another iMac as a display – though not old enough to act as a display itself.
Use your iMac as a display with target display mode - Apple Support
"To exit target display mode, press Command-F2 again. Or disconnect the cable, or restart either Mac."
When the "Mid 2018" iMac wakes up, and the Mid 2014 iMac is no longer acting as a second screen, the OP could try pressing Command-F2 again on the Mid 2014 iMac.
If that works, great. If not, I don't think Apple is going to be fixing any bugs in Target Display Mode any time soon.