Macbook hangs when when unplugging external Monitor

Solution 1:

It appears a SMC reset will fix your issue. I just answered another question pertaining to display issues. I've included the same information directly from Apple as I did with the last question.

Have you tried resetting the SMC (System Management Controller)?

With charger plugged in, hold Shift-Control-Option on the left side of the keyboard, then press the Power.

The LED on MagSafe power adapters might change states or temporarily turn off when you reset the SMC.

Indicators that your SMC might need to be reset

  • The computer fans run at high speed, though the computer is not experiencing heavy usage and is properly ventilated.
  • The keyboard backlight behaves incorrectly on Mac computers that have this feature.
  • The status indicator light (SIL) behaves incorrectly on Mac computers that have this feature.
  • Battery indicator lights, if present, behave incorrectly on Mac notebooks that have a non-removable battery.
  • The display backlight doesn't respond correctly to ambient light changes on Mac computers that have this feature.
  • The computer doesn't respond to the power button when pressed.
  • A Mac notebook computer doesn't respond properly when you close or open the lid.
  • The computer sleeps or shuts down unexpectedly.
  • The battery doesn't charge properly.
  • The MagSafe power adapter LED doesn't indicate the correct activity.
  • The computer is performing unusually slowly, though it isn't experiencing abnormally high CPU utilization.
  • Application icons may bounce in the Dock for an extended amount of time when opened.
  • Applications may not function correctly, or they may stop responding after being opened.
  • A computer that supports target display mode does not switch into or out of target display mode as expected, or it switches into or out of target display mode at unexpected times.
  • The illumination around the I/O ports on a Mac Pro (Late 2013) does not activate when you move the computer.

Source: https://support.apple.com/kb/HT201295