Two-stage thermal gasification of polyolefins