close method
Cleans up all registered objects.
This method invokes the 'onClose' method for each object that has been registered.
Registered objects are removed so that subsequent invocations of this method have no effect.
Implementation
Future close() async {
await Future.wait(_registrations.map((r) => r.close()));
_registrations = [];
}