How does gravity affect a star's life cycle?