How to delete an endpoint only if exists
IF EXISTS ( SELECT * FROM sys.tcp_endpoints WHERE name = 'End_Mirroring')
DROP ENDPOINT End_Mirroring;
IF EXISTS ( SELECT * FROM sys.certificates WHERE name = 'PRIM_cert' )
DROP CERTIFICATE PRIM_cert;
IF EXISTS (SELECT * FROM sys.symmetric_keys WHERE [name] LIKE '%DatabaseMasterKey%')
DROP MASTER KEY";


OK, found it :)