Fix some NULL pointers

GLib catched these errors but it's wrong nevertheless.
Always close tabbed's stdout when finished reading
Warn when the XID from tabbed is 0