Fix IllegalStateException triggered while shutting down ThreadPerChannelEventLoopGroup

- Fix #1718
- Add the test case contributed by @mkw