Strange new behavior (to me anyway) since upgrading to macOS Sierra (10.12):
When I move between using my MacBook with a Thunderbolt display (only), and using it on with only the built-in display, it frequently leaves windows almost entirely off the side of the display. :/
(If it matters, this is with a sleep, between mode switches - like when moving between home and office.)
At no time was I using an extended desktop (multiple displays at once) - though it looks as if it somehow thinks it's in that mode. Though a trip to the Displays preference pane, shows that it is indeed using only only display.
(More than once, I've also seen this: Upon wake, I see the Desktop - but no menubar. Perhaps another indication that it's confused and thinks there's another display - which has the menubar.)
I found some interesting suggestions on this SuperUser thread though none of those worked for me, and I just created a new account there (coulda sworn I had one, but whatever), so couldn't post there yet :/ - hopefully this link helps.
What _did_ work for me: Simply "Hide" (in the app menu, just to the right of the Apple menu) any app with windows off-screen; when the app was shown again, the windows were moved back onto the current (only) screen.
In the process I also discovered the missing "Detect Displays" button, which was removed from the Displays preference pane at some point - press (and hold) the Option key. It had no effect on this issue, though maybe handy to know.
(I have heard of folks seeing this issue on other releases like "El Capitan" (10.11) - hope this helps!)