You can use event dispatcher. When the backpack closes, call the dispatcher. Bind an event to that dispatcher that closes the inventory as well. (I would do the binding in the blueprint that creates and opens the backpack widget)
Note that you can link events directly or use “create event” to select an existing event. Its both kind of the same thing.
Here is an example from my project:
Widget:
Actor that creates and opens the widget:
Here are some more infos about event dispatchers:
[Documentation][3]
[Tutorial Video][4]