Added a types.h public header and closing streams if sender crashes.

Change-Id: Idd1a2046ff790a734673b06cf945d85a0db8ac94