It sounds like you are having problems with your filament out sensor.
#define FILAMENT_RUNOUT_SENSOR
First off do you have a filament out sensor. If not disable the above line.
If you have a filament runout sensor you may have it connect incorrectly or configured incorrectly.
My filament filament runout sensor needed to be inverted
#define FIL_RUNOUT_INVERTING true
and I needed to assign a pin for it to operate correctly in "pins_RAMPS.h"
#define FILAMENT_RUNOUT_SENSOR
First off do you have a filament out sensor. If not disable the above line.
If you have a filament runout sensor you may have it connect incorrectly or configured incorrectly.
My filament filament runout sensor needed to be inverted
#define FIL_RUNOUT_INVERTING true
and I needed to assign a pin for it to operate correctly in "pins_RAMPS.h"