Evolution of cooperation in an n-player game with opting out