utility function for creating observables for closeable resources