Motor2040 disconnects when running simple motor script

Hey:))

Im currently writing a script for the motor2040 board using Thonny and the 1.25 beta1 pimoroni micropython version. I have also tried version 1.23 to make sure its not a beta issue.
The script is a simple position control script for one motor similar to the one provided as an example but even further reduced. Everything seems to work fine but as soon as i set the DAMP factor to more than 6 i run in to the following error:

PROBLEM IN THONNY'S BACK-END: Exception while handling 'Run' (ConnectionError: read failed: [Errno 6] Device not configured).
See Thonny's backend.log for more info.
You may need to press "Stop/Restart" or hard-reset your MicroPython device and try again.

Process ended with exit code 1.
-----------------------
Unable to connect to /dev/cu.usbmodem2101: [Errno 2] could not open port /dev/cu.usbmodem2101: [Errno 2] No such file or directory: '/dev/cu.usbmodem2101'

Process ended with exit code 1.

A problem I could imagine is that for some reason the motor suddenly requires more current causing the board to temporarily reset and losing the connection however there is no torque on the motor and earlier test with the motor having to fight against more weight seemed to have no problems.
Other than that i was thinking that maybe the damp factor was causing speeds to get so small that the controller couldnt handle it anymore thats why I ended up limiting it to a min speed. But without luck.

I would really appreciate any leads or tips maybe someone has encountered that problem before:))

Script:

import time
import math
import random
from motor import Motor, motor2040
from encoder import Encoder, MMME_CPR

# Configuration
DIRECTION = 0
GEAR_RATIO = 298
COUNTS_PER_REV = MMME_CPR * GEAR_RATIO
RANGE = 180
DEADZONE = 3
DAMP = 10
MIN_SPEED = 0.2
MAX_IDLE = 1000  # 1000 * 0.01s = 10 seconds

# Setup motor and encoder
motor = Motor(motor2040.MOTOR_A, direction=DIRECTION)
encoder = Encoder(0, 0, motor2040.ENCODER_A, counts_per_rev=COUNTS_PER_REV, count_microsteps=True)

goal = random.randint(-RANGE, RANGE)
idle_counter = 0

try:
    while True:
        current_pos = encoder.degrees()
        error = current_pos - goal
        error_damp = error / DAMP
        speed = max(min(error_damp, 1.0), -1.0)

        if abs(error) > DEADZONE:
            if abs(speed) < MIN_SPEED:
                motor.speed(0)
            else:
                motor.speed(speed)
            idle_counter = 0
        else:
            motor.stop()
            idle_counter += 1

        # Refresh goal if motor has been idle too long
        if idle_counter >= MAX_IDLE:
            goal = random.randint(-RANGE, RANGE)
            print("New goal:", goal)
            idle_counter = 0

        time.sleep(0.01)

except Exception as e:
    print("Error:", e)
    motor.stop()

[EDIT]: Which release of the pimoroni micropython do you recommend im currently using the pico one but maybe thats not the right one?
Also the relationship to the DAMP factor is really weird because something around 10 will cause it to immediately crash but like 50 is fine again and runs without any errors.

Are you able to include a print of your speed value? Looking over your script, nothing jumps out to me as being particularly wrong, so I don’t know why the board would be crashing.