for bootstrap modal
Try $('#myModal').modal('hide')
For bootstrap popover
I just saw you are talking about a bootstrap dropdown not bootstrap modal:
In this case your approach is not bad, just remove the open class of the parent element.
In the example from the link above the first dropdown element has an id of “drop3”,
so to programatically close it you can do:
$('#drop3').parent().removeClass("open");