                         if ev.isReadable {
                             channel.readFromEventLoop()
                             
-                            guard channel.open else {
-                                safeDeregister(channel: channel)
+                            guard handleEvents(channel) else {
                                 continue
                             }
                         }
                         
+                        // Ensure we never reach here if the channel is not open anymore.
                         assert(channel.open)
-                        assert(ev.isReadable || ev.isWritable)
-                    
                     } else if ev.selectable is ServerSocket {
                         let socket = ev.selectable as! ServerSocket
                         

                            
                            let channel = Channel(socket: accepted, eventLoop: self)
                            channel.registerOnEventLoop(initPipeline: initPipeline)
                            if channel.socket.open {
                                channel.pipeline.fireChannelActive()
                            }
                        }

                }
            }
        }
    }

    private func handleEvents(_ channel: Channel) -> Bool {
        if channel.open {
            return true
        }
        do {
            try deregister(channel: channel)
        } catch {
            // ignore for now... We should most likely at least log this.
        }

        return false
    }
    
    public func close() throws {
