diff --git src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java
index 3715aca227..c8562143dd 100644
--- src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java
+++ src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java
@@ -12,6 +12,9 @@ import java.awt.Graphics2D;
 import java.awt.Point;
 import java.awt.event.KeyEvent;
 import java.awt.event.MouseEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowFocusListener;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -146,6 +149,14 @@ public class ParallelWayAction extends MapMode implements ModifierExListener {
 
     private final ParallelWayLayer temporaryLayer = new ParallelWayLayer();
 
+    /** #25012: a drag cannot continue once JOSM loses the focus, as the mouse release may go to another window */
+    private final WindowFocusListener focusListener = new WindowAdapter() {
+        @Override
+        public void windowLostFocus(WindowEvent e) {
+            cancelDrag();
+        }
+    };
+
     /**
      * Constructs a new {@code ParallelWayAction}.
      * @param mapFrame Map frame
@@ -175,6 +186,9 @@ public class ParallelWayAction extends MapMode implements ModifierExListener {
 
         // Needed to update the mouse cursor if modifiers are changed when the mouse is motionless
         MainApplication.getMap().keyDetector.addModifierExListener(this);
+        if (MainApplication.getMainFrame() != null) {
+            MainApplication.getMainFrame().addWindowFocusListener(focusListener);
+        }
         sourceWays = new LinkedHashSet<>(getLayerManager().getEditDataSet().getSelectedWays());
         for (Way w : sourceWays) {
             w.setHighlighted(true);
@@ -190,6 +204,9 @@ public class ParallelWayAction extends MapMode implements ModifierExListener {
         MapFrame map = MainApplication.getMap();
         map.statusLine.setDist(-1);
         map.keyDetector.removeModifierExListener(this);
+        if (MainApplication.getMainFrame() != null) {
+            MainApplication.getMainFrame().removeWindowFocusListener(focusListener);
+        }
         removeWayHighlighting(sourceWays);
         pWays = null;
         sourceWays = null;
@@ -281,6 +298,9 @@ public class ParallelWayAction extends MapMode implements ModifierExListener {
         if (e.getButton() != MouseEvent.BUTTON1)
             return;
 
+        // #25012: the release ending the previous drag never arrived, drop that drag and start afresh
+        cancelDrag();
+
         if (!sanityCheck())
             return;
 
@@ -305,7 +325,8 @@ public class ParallelWayAction extends MapMode implements ModifierExListener {
     public void mouseReleased(MouseEvent e) {
         updateModifiersState(e.getModifiersEx());
         // Other buttons are off limit, but we still get events.
-        if (e.getButton() != MouseEvent.BUTTON1)
+        // Ignore the release of a press that was not accepted or whose drag was cancelled.
+        if (e.getButton() != MouseEvent.BUTTON1 || !mouseIsDown)
             return;
 
         if (!mouseHasBeenDragged) {
@@ -515,6 +536,21 @@ public class ParallelWayAction extends MapMode implements ModifierExListener {
         sourceWays.clear();
     }
 
+    /**
+     * Cancels the drag in progress, if any. Nothing has been changed yet, since the parallel ways are only created
+     * when the mouse is released.
+     */
+    private void cancelDrag() {
+        if (mode == Mode.DRAGGING) {
+            pWays = null;
+            helperSegment = null;
+            setMode(Mode.NORMAL);
+            MainApplication.getMap().statusLine.setDist(-1);
+            temporaryLayer.invalidate();
+        }
+        resetMouseTrackingState();
+    }
+
     private void resetMouseTrackingState() {
         mouseIsDown = false;
         mousePressedPos = null;
diff --git test/unit/org/openstreetmap/josm/actions/mapmode/ParallelWayActionTest.java test/unit/org/openstreetmap/josm/actions/mapmode/ParallelWayActionTest.java
index 7159008da9..8b1f8d9f35 100644
--- test/unit/org/openstreetmap/josm/actions/mapmode/ParallelWayActionTest.java
+++ test/unit/org/openstreetmap/josm/actions/mapmode/ParallelWayActionTest.java
@@ -4,6 +4,10 @@ package org.openstreetmap.josm.actions.mapmode;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
+import java.awt.event.WindowFocusListener;
+
+import org.awaitility.Awaitility;
+import org.awaitility.Durations;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.openstreetmap.josm.TestUtils;
@@ -128,6 +132,75 @@ class ParallelWayActionTest {
         assertEquals(5, this.dataSet.getWays().size(), this.dataSet.getWays().toString());
     }
 
+    /**
+     * A drag whose mouse release was lost is dropped by the next press, which then starts a new drag.
+     * <p>
+     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/25012">#25012</a>: the press cleared the
+     * offset path but left the mode at dragging, so the next drag event threw a {@link NullPointerException}.
+     */
+    @Test
+    void testNonRegression25012() {
+        Node a = new Node(LatLon.ZERO);
+        Node b = new Node(new LatLon(0, 0.0001));
+        Way w = new Way();
+        w.addNode(a);
+        w.addNode(b);
+        this.dataSet.addPrimitive(a);
+        this.dataSet.addPrimitive(b);
+        this.dataSet.addPrimitive(w);
+        this.map.selectMapMode(mapMode);
+
+        // a drag whose release never arrives, e.g. because the focus moved to another application
+        mapMode.mousePressed(MapModeUtils.mouseClickAt(new LatLon(0, 0.00005)));
+        Awaitility.await().pollDelay(Durations.FIVE_HUNDRED_MILLISECONDS).until(() -> true);
+        mapMode.mouseDragged(MapModeUtils.mouseClickAt(new LatLon(0, 0.00005)));
+        mapMode.mouseDragged(MapModeUtils.mouseClickAt(new LatLon(0.00005, 0.00005)));
+        assertEquals(3, this.dataSet.allPrimitives().size(), "nothing is created before the release");
+
+        MapModeUtils.dragFromTo(new LatLon(0, 0.00005), new LatLon(-0.00005, 0.00005));
+        assertEquals(2, this.dataSet.getWays().size(), this.dataSet.getWays().toString());
+        assertEquals(6, this.dataSet.allPrimitives().size());
+    }
+
+    /**
+     * Losing the focus cancels the drag in progress, and the late release does not create or select anything.
+     * <p>
+     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/25012">#25012</a>: the preview stayed on
+     * screen until the next click.
+     * @throws ReflectiveOperationException if the private fields cannot be accessed
+     */
+    @Test
+    void testFocusLostCancelsDrag25012() throws ReflectiveOperationException {
+        Node a = new Node(LatLon.ZERO);
+        Node b = new Node(new LatLon(0, 0.0001));
+        Way w = new Way();
+        w.addNode(a);
+        w.addNode(b);
+        this.dataSet.addPrimitive(a);
+        this.dataSet.addPrimitive(b);
+        this.dataSet.addPrimitive(w);
+        this.map.selectMapMode(mapMode);
+
+        mapMode.mousePressed(MapModeUtils.mouseClickAt(new LatLon(0, 0.00005)));
+        Awaitility.await().pollDelay(Durations.FIVE_HUNDRED_MILLISECONDS).until(() -> true);
+        mapMode.mouseDragged(MapModeUtils.mouseClickAt(new LatLon(0, 0.00005)));
+        mapMode.mouseDragged(MapModeUtils.mouseClickAt(new LatLon(0.00005, 0.00005)));
+        assertEquals(Mode.DRAGGING, TestUtils.getPrivateField(mapMode, "mode"));
+
+        ((WindowFocusListener) TestUtils.getPrivateField(mapMode, "focusListener")).windowLostFocus(null);
+        assertEquals(Mode.NORMAL, TestUtils.getPrivateField(mapMode, "mode"), "the preview is still drawn");
+
+        // the release arrives later, e.g. on a platform where it goes to the window of the press anyway, here back
+        // on the way, where a click would select it
+        this.dataSet.clearSelection();
+        mapMode.mouseReleased(MapModeUtils.mouseClickAt(new LatLon(0, 0.00005)));
+        assertEquals(3, this.dataSet.allPrimitives().size(), "the cancelled drag has been committed");
+        assertTrue(this.dataSet.getSelected().isEmpty(), "the release has been taken as a click");
+
+        MapModeUtils.dragFromTo(new LatLon(0, 0.00005), new LatLon(-0.00005, 0.00005));
+        assertEquals(6, this.dataSet.allPrimitives().size());
+    }
+
     /**
      * Unit test of {@link Mode} enum.
      */
