Thank you for all the information you provided about what is going on. It sounds like you have to manually power your iMac off when you power off your second display since upgrading to OS X Mavericks.
I found an article with steps to troubleshoot issues with displays. I recommend reviewing the section titled "No video or no signal, image distortion, 'snow,' or flickering" in the article below. I recommend reviewing the full article, but the following steps specifically stands out to me for the situation you are experiencing:
Reset the system
You can find the full article here:
Thank you for posting in the Apple Support Communities.