How to disable a block programmaticaly with drupal 8

On my custom theme i have a region with 2 blocks. It is an event region block. The first block is a header block and the second block is a view block that renders the active - running events. However when there are no events the view result is an empty result so nothing is rendered but the header events block remains there.
Subscribe to RSS - preprocess
this is an arrow pointing back to the top of the page