Target Display Mode troubles, can't disconnect anymore I used to run my 15" MBP with 21.5" iMac in Target Display Mode and everything was fine for a while. But as of a couple recent macOS upgrades, every time I disconnect, the iMac never restores to it's previous state. The screen is black. Once in a while, after 10 minutes or longer, it would come back. But more often than not, I have to power-cycle my iMac.

I have tried every way possible to connect/disconnect. Different port combos, Apple genuine cable, unplugging Thunderbolt physically, Cmd+F2. All of this used to work, but not anymore. 

It's really annoying because even if I let my MBP go to hibernate/sleep/screen-off, I end up having to power-cycle my iMac.

Any suggestions would really be appreciated. Is anyone having this experience, as it doesn't seem common? 

I have not found anyone complaining about this exact problem.
I have the same issue and here’s why it’s a software bug.

On my 2013 21.5" iMac (base model with the only upgrade being a factory installed 256GB SSD). I've never had any work done on it.

I attached an external drive running 10.11 El Capitan and booted from it. Activated target display mode, then deactivated it. NO ISSUE, IT WORKED! So I thought maybe there's something corrupted in my install and I have to erase and start from scratch. Before I did that, I clean installed Mac OS High Sierra on my external drive. ISSUE REOCCURED on a fresh install! Then I installed the Mojave Beta to see if Apple fixed it. NOPE it still cannot deactivated Target Display mode without screwing up the internal monitor!

I've discovered though that plugging in an external DisplayPort display to the iMac "re-wakes" the internal display as it activates the external one. It's only slightly better than having to restart, as you still need to reach behind and plug in and out cables. Frustrating. I have an open ticket with Apple Support.

Basically, the problem isn't our computers or our installs. It's Mac OS High Sierra and Mojave (and maybe regular Sierra, I can't tell). El Capitan doesn't have this problem.