Keyboard Maestro is probably the right tool for the job. You could use a wireless network trigger, and then setup the rest of the macro to open or close whatever you want.
Might also be worth looking at Brett Terpstra’s Bunch that allows a batch file (“bunch”) of apps and windows to be opened or closed at one sitting — I’m not sure it has location based triggers though (you could do that with Shortcut perhaps though maybe that’s just a step too complicated?)
Look at Hookmark to create URLs to specific files(this is not needed but makes launching easier), then keyboard maestro or Alfred to launch the urls. Location triggers - do you use a keyboard or other specific device at home? Keyboard maestro has usb device triggers.
My other devices got me to try a Mac, KM is what made me fall in love.
edit: Now I am absolutely Mac first (such that my phone and iPad is are used very little, but I somehow own 3 Macs and I feel environmentally irresponsible)
My current setup includes a Raspberry Pi Pico with a RFID reader using Keyboard Maestro public web macros to kick off automation. (Also - via different URLs - to tickle PushCut into running shortcuts.)
Note my RFID cards include semi-blank ones, cruise cards, and old credit cards. (I have a mini labeller to keep straight what each kicks off.)
Yes, Bunch would do the trick combined with location-based shortcuts. The only shortcoming would be that Bunch would only quit or launch apps, folders, and docs but does not take care of the windows layouts by itself, although it can be integrated with Moom for that.
Some strenghts of Bunch: free, text-based configuration and has deep integration capabilities with almost anything. But for this use case the best thing is that Bunch can track wich apps are open and perform closing & cleanup actions when the context (aka “bunch”) has changed.
The main problem I see is the lack of an Automation Trigger for macOS Shortcuts, as we do have in iOS.
Keyboard Maestro URLs triggered from your iPhone Shortctus (iOS has those triggers macOS lacks) when it reaches a given location could be a way to work around this limitation. (That’s what I do, but @MartinPacker’s solution is definetly something to lo and behold in all its nerdiness glory! )
That part can be done via Shortcuts, even with some window management in it, but you’ll still need to trigger this shortcut manually.