Invariant sets and control synthesis for switching systems with safety specifications