Blocking out distractions is the key to doing anything productive. In the case of writing you need to put yourself in a situation where all you can do is write. There are two methods I like to employ, one digital and the other analogue. On my computer I use an application called PyRoom which places a black fullscreen interface over my entire monitor with only a green box in the middle where I type. There is no option to use it in windowed mode, so you can't see notifications happening in the background. PyRoom is a Linux only application, but the paradigm of blacking out the rest of the screen is one that many application developers build upon.
The other method is to take a notepad somewhere and sit down to write. A good place to go is a coffee shop, or a park, or perhaps even oscillate between both. Being away from your computer like this with a non-interactive medium such as paper is a great way to get yourself focused on the task at hand.
In both cases, some lyricless music is also good. It stops your mind from picking up on every little noise that is happening around you. The human mind has a really annoying habit of filling silence with it's own noise when it's not tired, and silencing that noise with music works really well.
Basically, hide your distractions.