Compactness of Schr\"odinger semigroups