My question is, If one masterbate’s however due to the guilt of doing he refrains and does not end up ejaculating, is ghusl required? I am well aware that this is a sin, and I’m trying my best to avoid this sin.

Keep trying to avoid it. Seek divine intervention in doing so by constantly asking Allah to soften your heart.

Ghusl is required based on precaution.