added possibility to register for shutdown, so resource can be cleared