Fix I/O closed on write by waiting for write end, fix subsubprocess not being killed.