Connecting second screen via Thunderbolt and HDMI
There is a product that should be able to fix this issue for you:  Stay

From their website:


  Stay can store a set of windows for every combination of displays that
  you use with your computer. Stay can also be configured to
  automatically restore windows as displays are connected and
  disconnected.