diff --git a/gdb/testsuite/gdb.multi/checkpoint-multi.exp b/gdb/testsuite/gdb.multi/checkpoint-multi.exp
index ac9890682c1..4dcb579bf4a 100644
--- a/gdb/testsuite/gdb.multi/checkpoint-multi.exp
+++ b/gdb/testsuite/gdb.multi/checkpoint-multi.exp
@@ -148,7 +148,13 @@ proc start_2_inferiors_checkpoint_on_inf_2_alt {} {
 
 with_test_prefix "check detach on non-checkpointed inferior" {
     start_2_inferiors_checkpoint_on_inf_2
+    set pid [get_inferior_pid]
     gdb_test "detach" "Detaching from program.*$::exec1.*Inferior 1.*detached.*"
+    with_test_prefix cleanup {
+	gdb_test "inferior 1" "Switching to inferior 1 .*"
+	gdb_test "attach $pid" "Attaching to program: .*" "re-attach for kill"
+	gdb_test_kill "kill" 1
+    }
 }
 
 with_test_prefix "check kill on non-checkpointed inferior" {
