Granit Xhaka's 74th-minute goal earned the Group E winners victory and ended the visitors' hopes of claiming second spot in the pool.
Iceland held on to the play-off spot thanks to their 1-1 draw in Norway as Slovenia finished two points behind in third.
Nejc Pecnik fired in a shot after eight minutes which home goalkeeper Yann Sommer tipped over the bar.
Slovenia goalkeeper Samir Handanovic then punched away a Haris Seferovic header before parried away a Reto Ziegler free-kick.
The Inter Milan keeper was keeping his side in it at the end of the first half as he produced another fine save, tipping over Admir Mehmedi's shot following a corner.
The Swiss pressure continued after the break as Haris Seferovic headed over from a Barnetta free-kick.
Slovenia knew just one goal could put them in the play-offs, though, and Kevin Kampl brought a superb save out of Sommer.
They were undone in the 74th minute, however, as Xhaka received the ball from Blerim Dzemaili and crashed a finish into the top corner from 20 yards.
Slovenia responded well as they looked to stage a late fightback, Milivoje Novakovic and Zlatan Ljubijankic both heading against the bar in a mad goal-mouth scramble, but they ran out of time as defeat ended their World Cup hopes.