I just realized looking this over a second time that this is not quite the right way to do things. `close` (and `error)` are given to you; you do not get to say what steps they run. Instead, you should do something like

"When the TCP connection has been closed cleanly by the server, `close` MUST be called, and additionally the following steps must be run:"