Added close handler fn to have more control what happens when a channel closes.