Stay.app
… allows you to store desired locations of windows for all applications in multiple states (laptop screen only, plus external display, external display only) and the app can automatically switch between them when the display setup changes. In addition, you can use Stay.app to restore window positions even without changing your display arrangement.