is there a script to block outbound connection if vpn disconnects?
Some VPN providers have 'Internet kill switches' for their VPN that will cut your Internet connection in case of a disconnect so check yours.

There is a large number of 3d party applications that will disable the outbound traffic if VPN disconnect.

VPN watcher...and others.

I suggest you use one of those, since making a script would be like reinventing the wheel.

But if you have to here are the instructions how to.

Creating a kill switch for the OSX VPN client